# L-6 MCS 275 Mon 28 Jan 2008 : palindromes.py

# a word is a palindrome 
# if reading forward and backward is the same

def is_palindrome(x):
   """
   returns true if x is a palindrome
   """
   if len(x) <= 1:
      return True
   elif x[0] != x[len(x)-1]:
      return False
   elif len(x) == 2:
      return True
   else:
      y = x[1:len(x)-1]
      return is_palindrome(y)

def main():
   """
   prompts the user for a word and checks
   if it is a palindrome
   """
   w = raw_input('give a word : ')
   s = 'the word \"' + w + '\" is '
   if not is_palindrome(w):
      s = s + 'not '
   s =  s + 'a palindrome'
   print s

if __name__ == "__main__": main()
