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

Enter any Number 5245

Number is Not Palindrome

>>> 

=================== 

Enter any Number 10001

Number is Palindrome 

>>> 

CCC Online Test Python Programming Tutorials Best Computer Training Institute in Prayagraj (Allahabad) Online Exam Quiz O Level NIELIT Study material and Quiz Bank SSC Railway TET UPTET Question Bank career counselling in allahabad Best Website and Software Company in Allahabad Website development Company in Allahabad