In [6]:
#A number is palindrome if reverse of the number is equal to the number
num = int (input ('Enter a number: '))
number = num
rev = 0
while num != 0:
r = int (num % 10)
rev = int(rev * 10 + r)
num = int (num / 10)
if rev == number:
print (number, ' is Palindrome.')
else:
print ('Not Palindrome.')
Enter a number: 1221 1221 is Palindrome.
No comments:
Post a Comment