My task is to define a procedure is_palindrome, that takes as input a string, and returns a boolean indicating if the input string is a palindrome. In this case a single let
def is_palindrome(s): if not s: return True else: return s[0]==s[-1] and is_palindrome(s[1:-1])
or, if you want a one-liner:
def is_palindrome(s): return (not s) or (s[0]==s[-1] and is_palindrome(s[1:-1]))
Hope that helps