Python program to check given number is Palindrome or not


Following Python program checks the given integer or number is Palindrome or not using math.log() + recursion + list comprehension

import math
   
def rev(num):
    return int(num != 0) and ((num % 10) * \
             (10**int(math.log(num, 10))) + \
                          rev(num // 10))
  
test_number = 9669669
  
# for checking a number is palindrome
res = test_number == rev(test_number)
  
# printing result
print ("Is the number palindrome ? : " + str(res))

Output:

Is the number palindrome ? : True

Try it Online here https://onecompiler.com/python/3x73jpvx4