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.
Palindrome number is an integer whose reverse is equal to the number itself, for example the reverse of 121 is equal to 121 which is the number itself, then it is a palindrome number, whereas the reverse of 123 is equal to 321 which is not equal to the number itself, that is 123, therefore it is not a palindrome number.
Following python program ask from user to check whether it is a palindrome number or not:
# Python Program - Check Palindrome Number or Not print("Enter 'x' for exit."); num = input("Enter any number to check for palindrome: "); if num == 'x': exit(); 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."); else: print(orig, "is not a Palindrome Number.");
Here is the sample run of the above Python program to illustrate how to check for palindrome number:
Now let's enter any number to find out whether it is a palindrome or not say 28982:
Now re-run the same program again and this time check a number for palindrome say 28976:
Below is the same program on python shell:
You may also like to learn or practice the same program in other popular programming languages: