python recursion return palindrome number code example
Example 1: palindrome rearranging python
import collections
def palindromeRearranging(inputString):
cnt = collections.Counter()
odds = 0
for i in range(len(inputString)):
cnt[inputString[i]] += 1
for i in cnt:
if cnt[i]%2 == 1:
odds += 1
return odds <= 1
Example 2: palindrome number + python
number=int(input("Enter any number :"))
temp=number
reverse_num=0
while(number>0):
digit=number%10
reverse_num=reverse_num*10+digit
number=number//10
if(temp==reverse_num):
print("The number is palindrome!")
else:
print("Not a palindrome!")