### Longest Palindrome

Find the length of the longest substring in the given string `s` that is the same in reverse.        

As an example, if the input was “I like racecars that go fast”, the substring (`racecar`) length would be `7`. 

If the length of the input string is `0`, the return value must be `0`. 

### Example:
```
"a" -> 1 
"aab" -> 2  
"abcde" -> 1
"zzbaabcd" -> 4
"" -> 0
```

Source: codewars | Difficulty: EASY
Tags: Fundamentals

Starter code: def longest_palindrome (s):
	

Solutions:
def longest_palindrome(s):
	(maxPal, tmpPal) = (0, 1)
	count_dct = {}
	inPal = False
	for (i, l) in enumerate(s):
		count_dct[l] = count_dct.get(l, 0) + 1
		if not inPal and count_dct[l] >= 2:
			if l == s[i - 1]:
				inPal = True
				tmpPal = 2
			elif l == s[i - 2]:
				inPal = True
				tmpPal = 3
		elif inPal and l == s[max(0, i - tmpPal - 1)]:
			tmpPal += 2
		else:
			inPal = False
			tmpPal = 1
		maxPal = max(maxPal, tmpPal)
	return maxPal


def longest_palindrome(s):
	if not s:
		return 0
	substrings = [s[i:j] for i in range(0, len(s)) for j in range(i, len(s) + 1)]
	return max((len(s) for s in substrings if s == s[::-1]))


def longest_palindrome(s):
	return max((n for n in range(len(s), 0, -1) for i in range(len(s) - n + 1) if s[i:i + n] == s[i:i + n][::-1]), default=0)


def longest_palindrome(s):
	if s:
		return max(map(len, filter(palindrome, substrings(s))))
	else:
		return 0

def palindrome(s):
	return s[::-1] == s

def substrings(s):
	return [s[i:j + 1] for i in range(0, len(s)) for j in range(i, len(s))]


def longest_palindrome(s):
	longest = 0
	for j in range(1, len(s) + 1):
		for i in range(j):
			t = s[i:j]
			if t == t[::-1]:
				longest = max(longest, len(t))
	return longest