In this Python program, we will learn how to check if the given number is palindrome or not.
A palindrome is a word, number, phrase, or other sequences of characters that reads the same backward as forward, such as civic or rotator or the number 14241.
A number is a palindrome when we reverse the number and the reversed number is equal to the original number.
Here is the code of the program to check if the given number is palindrome or not.
Python Program to Check whether the Number is Palindrome or Not
# Python Program to Check whether the Number is Palindrome or Not
# To take input from the User
num = int(input("Enter The Number: "))
temp = num
rev = 0
while temp != 0:
rev = (rev * 10) + (temp % 10)
temp = temp // 10
if num == rev:
print(num,"is palindrome")
else:
print(num,"is not a palindrome")
Enter The Number: 121
121 is palindrome
Enter The Number: 653
653 is not a palindrome
Comments