def isPalindrome(string): #termination condition: the string is one character or less if (len(string) <= 1): return True if (string == string[-1]): return isPalindrome(string[1:-1]) else: return False
Here is what the above code is Doing:
1. If the string is one character or less, it's a palindrome.
2. If the first and last characters are the same, we check the string in between.
3. If the first and last characters are not the same, it's not a palindrome.