Longest palindromic stretch
Write longest_palindrome(text) that returns the longest stretch of consecutive
characters that reads the same backwards. If several tie, return the leftmost.
longest_palindrome("babad") -> "bab"
longest_palindrome("cbbd") -> "bb"
longest_palindrome("") -> ""
Expand around every centre, both a single character and the gap between two characters. Quadratic in the worst case, which is fine for a few thousand characters.
def longest_palindrome(text):
...