def longest_palindrom(s): if s[::-1] == s: return len(s) else: return max(longest_palindrom(s[:-1]), longest_palindrom(s[1:]))