codescracker


python

Python Program to Check Palindrome



« Previous Program Next Program »


Check Palindrome in Python

To check whether the given number is a palindrome number or not a palindrome number in python, you have to ask from user to enter a number to check for palindrome number as shown in the program given here.

Python Programming Code to Check Palindrome

Following python program ask from user to check whether it is a palindrome number or not:

# Python Program - Check Palindrome Number or Not
		
while True:
	print("Enter 'x' for exit.")
	num = input("Enter any number: ")
	if num == 'x':
		break
	else:
		number = int(num)
		orig = number
		rev = 0
		while number > 0:
			rev = (rev*10) + number%10
			number //= 10
		if orig == rev:
			print(orig, "is a Palindrome Number.\n")
		else:
			print(orig, "is not a Palindrome Number.\n")

Here is the sample run of the above Python program to illustrate how to check for palindrome number:

python check palindrome number

Same Program in Other Languages

You may also like to learn or practice the same program in other popular programming languages:


« Previous Program Next Program »




Tools
Calculator

Quick Links
Signup - Login - Give Online Test