Programming Examples
Python program to check number is Palindrome or not using function
Write a Python program to input any number and check number is Palindrome or Not using Function
Solution
def reverse(num):
rev=0
while num>0:
rev=rev*10+(num%10)
num=num//10
return rev
num=int(input("Enter any Number "))
ans=reverse(num)
if num==ans:
print("Number is Palindrome ")
else:
print("Number is Not Palindrome")
Output/ Explanation:
Enter any Number 5245
Number is Not Palindrome
>>>
===================
Enter any Number 10001
Number is Palindrome
>>>