1. # determines whether or not an integer is a palindrome;
  2. # that is, if it reads the same from both ways
  3. def isPalindrome(n):
  4.     s = str(n)
  5.     reverseString = ""
  6.    
  7.     for i in range (len(s) - 1, -1, -1):
  8.         reverseString += s[i]

  9.     return reverseString == s
  10.        
  11. print (isPalindrome(1)) # True
  12. print (isPalindrome(9009)); # True
  13. print (isPalindrome(90109)); # True
  14. print (isPalindrome(1212)); # False
DOWNLOAD

              Created: February 19, 2014
Completed in full by: Michael Yaworski