To Find whether the given number is a palindrome number or not in python
PROGRAM CODING
num=int(input("Enter a number"))
revnum=0
cnum=num
while num>0:
revnum=revnum*10+num%10
num=num//10
if revnum==cnum:
print("The given number is a palindrome number")
else:
print("The given number is not a palindrome number")
EXPLANATION OF THE PROGRAM
revnum mean reverse of a number, whatever we give it will work but as a appropriate meaning revnum is correct
cnum is copy of the number
// - Floor division
- First you have to give a number, input will take it as a string and int will change the string into integer.
- We are associating 0(zero) to revnum
- And then we took a copy of the num as cnum
- while num>0 : is a condition when it becomes true the following loop will be executed
Comments
Post a Comment