functionsscopingand abstraction palindromes recursion is also useful for many problems that do not involve numbers figure contains functionispalindromethat checks whether string reads the same way backwards and forwards def ispalindrome( )"""assumes is str returns true if the letters in form palindromefalse otherwise non-letters and capitalization are ignored ""def tochars( ) lower(letters 'for in sif in 'abcdefghijklmnopqrstuvwxyz'letters letters return letters def ispal( )if len( < return true elsereturn [ = [- and ispal( [ :- ]return ispal(tochars( )figure palindrome testing the function ispalindrome contains two internal helper functions this should be of no interest to clients of the functionwho should care only that ispalindrome meets its specification but you should carebecause there are things to learn by examining the implementation the helper function tochars converts all letters to lowercase and removes all non-letters it starts by using built-in method on strings to generate string that is identical to sexcept that all uppercase letters have been converted to lowercase we will talk lot more about method invocation when we get to classes for nowthink of it as peculiar syntax for function call instead of putting the first (and in this case onlyargument inside parentheses following the function namewe use dot notation to place that argument before the function name the helper function ispal uses recursion to do the real work the two base cases are strings of length zero or one this means that the recursive part of the implementation is reached only on strings of length two or more the conjunction in the else clause is evaluated from left to right the code first checks whether the first and last characters are the sameand if they are goes on to check whether the string minus those two characters is palindrome that the second conjunct is not evaluated unless the first conjunct evaluates to when two boolean-valued expressions are connected by "and,each expression is called conjunct if they are connected by "or,they are called disjuncts