DOWNLOAD
- # determines whether or not an integer is a palindrome;
- # that is, if it reads the same from both ways
- def isPalindrome(n):
- s = str(n)
- reverseString = ""
- for i in range (len(s) - 1, -1, -1):
- reverseString += s[i]
- return reverseString == s
- print (isPalindrome(1)) # True
- print (isPalindrome(9009)); # True
- print (isPalindrome(90109)); # True
- print (isPalindrome(1212)); # False
Created: February 19, 2014
Completed in full by: Michael Yaworski