def palindrome(s): #1. deal with base cases if len(s) <= 1: return True #2. break up the string #ends_match = s[0] == s[len(s)-1] if s[0] == s[len(s)-1]: ends_match = True else: ends_match = False rest_of_the_string_matches = palindrome(s[1:len(s)-1]) #3. combine answers return ends_match and rest_of_the_string_matches print "BANANA: " + str(palindrome("BANANA")) print "RACECAR: " + str(palindrome("RACECAR")) print "AMANAPLANACANALPANAMA: " + str(palindrome("AMANAPLANACANALPANAMA")) print "ERIKANDERSEN: " + str(palindrome("ERIKANDERSEN"))