Python Program to Check Palindrome Number

This python programs check whether a given number is Palindrome or not. A palindrome number is a number that remains the same when its digits are reversed.

Palindrome Number Examples: 111, 222, 1221, 24642, ... etc.

Python Source Code: 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

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

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