def ispalindrome(s):
    """
    Returns true if s is a palindrome

    There are two ways to define a palindrome:
      1. s is a palindrome if it reads the same backward
         and forward.
      2. s is a palindrome if either
         (1) its length is <= 1   OR
         (2) its first and last chars are the same and the
             string between them is a palindrome.
      Letters must match exactly.

    Parameter s: the candidate palindrome
    Precondition s is a string
    """
    assert type(s) == str, repr(s) + ' is not a string'     # get in the habit

    # Base palindrome
    if len(s) < 2:
        return True

    # s has at least 2 characters
    ends = s[0] == s[-1]
    middle = ispalindrome(s[1:-1])

    # Both must be true to be a palindrome
    return ends and middle