Input a number and check it is a palindrome number or not using while loop in Python
while Loop - Question 14
In this question, we will see how to input a number and check if it is a palindrome number or not in Python programming using while loop. To know more about while loop click on the while loop lesson.
Q14) Write a program in Python to input a number and check if it is a palindrome number or not using while loop.
Palindrome numbers are such numbers whose reverse is same as the original number. Example, 121, 14541, 22 etc.
Program
rev=0
n=int(input('Enter any number '))
on=n # storing the original number
while n>0:
d=n%10
rev=(rev*10)+d # reverse the number
n=n//10
if on==rev:
print('Palindrome Number')
else:
print('Not Palindrome Number')
Output
Enter any number 14541 Palindrome Number