Python Program to check a number is a palindrome or not using recursion
In this program, you will learn how to check a number is a palindrome or not using recursion in Python.
Some list of palindrome numbers are : 11 22 121 41214
Example: How to check a number is a palindrome or not using recursion in Python
rev = 0
def reverse(n):
global rev
if n > 0:
r = n % 10
rev = rev * 10 + r
reverse(int(n / 10))
return rev
n = int(input("Enter a number:"))
num = reverse(n)
if num == n:
print("Number is palindrome:", n)
else:
print("Number is not palindrome:", n)
Output:
Enter a number:121
Number is palindrome: 121