Home » Palindrome Program in Python

# Palindrome Program in Python

Learn about Palindrome Program in Python in the below code example. Also, refer to the comments in the code snippet to get a detailed view about what’s actually happening.

A palindrome number is one that remains the same when its digits are reversed. This Python program determines whether a given number is a Palindrome or not.

Example: 12321
Output:
12321 a Palindrome number

Contents

#### Palindrome Program in Python

The below python program decides whether a given number is a palindrome or not. The input number is read from the user.

Program:

``````# Python program to check if number is Palindrome

# input number
num = int(input('Enter the number : '))

# calculate reverse of number
reverse = 0
number = num
while(num != 0):
remainder = num % 10
reverse = reverse * 10 + remainder
num = int(num / 10)

# compare reverse number to original number
if(number == reverse):
print(number,'is a Palindrome')
else:
print(number,'is not a Palindrome')``````

Output:

Enter the number : 12321
12321 is a Palindrome

Hope above code works for you and Refer the below Related Codes to gain more insights. Happy coding and come back again.

Similar Code : Prime Number Using Recursion in Python