# L-8 MCS 275 Fri 27 Jan 2017 : palindromes.py

"""
A word is a palindrome if reading forward and backward
yields the same word.  This script contains a function
that recursively checks whether a word is a palindrome.
"""

def is_palindrome(word):
    """
    Returns True if word is a palindrome,
    and returns False otherwise.
    """
    if len(word) <= 1:
        return True
    elif word[0] != word[len(word)-1]:
        return False
    elif len(word) == 2:
        return True
    else:
        short = word[1:len(word)-1]
        return is_palindrome(short)

def main():
    """
    Prompts the user for a word and checks
    if it is a palindrome.
    """
    word = input('give a word : ')
    prt = 'the word \"' + word + '\" is '
    if not is_palindrome(word):
        prt = prt + 'not '
    prt = prt + 'a palindrome'
    print(prt)

if __name__ == "__main__":
    main()
