Python Online Compiler
Example: Python Program to Check Palindrome Number using While loop
C
C++
C#
Java
Python
PHP
main.py
STDIN
Run
# Python Program to Check Palindrome Number using While loop print ("Enter an integer number::\n") x, r, rN, oN = int(input()), 0, 0, 0 # rN - To store the reverse number # oN - To store the original number # r - To store the remainder oN = x # this reverse number will be stored during iteration while x!= 0: r = x % 10 r = r if r >= 1 else 0 rN = rN * 10 + r rN = round (rN) if rN else 0 x /= 10 x = x if x >= 1 else 0 rN = round (rN) if rN else 0 # if the original number will match with reverse # then the palindrome case will be true if oN == rN: print ("This ", oN, " is a palindrome number.") else: print ("This ", oN, " is not a palindrome number!")
90009
Output
Clear
ADVERTISEMENTS