Python Program to Check Palindrome Number

Palindrome Number:
A palindrome number is a number that remains the same when its digits are reversed.
For example: 1221, 24642 etc.

Python Program to Check Palindrome Number


# Python Program to Check Palindrome Number

# Reading Number and Converting to Integer
number = int(input('Enter Number: '))
copy = number

# Set Reverse variable to 0
reverse = 0

# Finding Reverse
while number != 0:
    remainder = number%10
    reverse = reverse *10 + remainder
    number = number//10

# Checking for Palindrome
if copy == reverse:
    print('%d is PALINDROME' %(copy))
else:
    print('%d is NOT PALINDROME' %(copy))

Output of Above Program

Run 1:
-------------
Enter Number: 12321
12321 is PALINDROME

Run 2:
-------------
Enter Number: 1234
1234 is NOT PALINDROME