# short version def isPalindrome(word): # word[::-1] means: return word the beginning to the end with step of "-1" (print the last letter first and then continue backwards) # word[::-1] reverses the word (easily Googleable) # word == word[::-1] returns True if the word is the same when reversed and False if is not the same return word == word[::-1] # long version def isPalindrome(word): # iterate over the first half of letters in the word for n in range(len(word)/2): # if the n-th letter is not the same as the n-th letter from the end (e.g. first and last letter) the word is not a palindrome → if word[n] != word[(n+1)*-1]: # → therefore return False (not a palindrome) return False # if all letters in the word matched, "return False" was not executed, therefore the word is a palindrome → return True return True print isPalindrome("racecar")