Check Palindrome Number in Python
Here you will get an example code to check palindrome number in python programming.
What is palindrome number in python
A number that can be read same as backward is called palindrome number. for example:
12321 is palindrome number
12342 is not palindrome number
Program Code to Check Palindrome Number in Python
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 | #Python Program to Check Palindrome Number num = int(input("Enter an integer : ")) num1=num # reverse the integer rev = 0 while(num !=0): digit = num % 10 rev = (rev * 10) + digit num = num//10 # checks if reverse number and original number is same if num1 == rev: print("The number is palindrome") else: print("The number is not palindrome") |
Output 1
Enter an integer : 12321
The number is palindrome
Output 2
Enter an integer : 1234
The number is not palindrome
Check out our other Python Programming Examples