Try this:
for i in range(len(str)): for j in range(i, len(str)): if str[i:j] == str[i:j][::-1]: #...
Try this:
Choose the start and end indices. Then take a slice to see if it's a palindrome. Nice and speedy! :)