Python Program to Check if a Number is a Palindrome | python program to check a number is a palindrome or not using while |
Python Program to Check if a Number is a Palindrome
Python Program to Check if a Number is a Palindrome
Palindrome number |
n=int(input("Enter number:"))
temp=n
rev=0
while(n>0):
dig=n%10
rev=rev*10+dig
n=n//10
if(temp==rev):
print("The number is a palindrome!")
else:
print("The number isn't a palindrome!")
temp=n
rev=0
while(n>0):
dig=n%10
rev=rev*10+dig
n=n//10
if(temp==rev):
print("The number is a palindrome!")
else:
print("The number isn't a palindrome!")
Output -
Case 1
Enter number:121
The number is a palindrome!
Case 2
Enter number:567
The number isn't a palindrome!
Enter number:121
The number is a palindrome!
Case 2
Enter number:567
The number isn't a palindrome!
Post a Comment