Skip to content
Home » Program to check if a given number is a palindrome or not in Python

Program to check if a given number is a palindrome or not in Python

A palindrome number’s reversed number is same as the number.

num=int(input("Enter number:"))
pnum=num
rev=0
while (pnum>0):
    dig=pnum%10
    rev=rev*10+dig
    pnum//=10
if num==rev:
    print("Number", num, "is a Palindrome")
else:
    print("Number", num, "is not a Palindrome")

Output 1:

Enter number:76

Number 76 is not a Palindrome

Output 2:

Enter number:65756

Number 65756 is a Palindrome