I hope this question is okay to ask on Code Review; this is a little function I wrote in Python 2.7.12 that checks if a number is a palindrome. It works fine but I'd like to know if there is a purely mathematical way to do it without using string conversion.
Here is the function:
def is_palindrome(n): forward = str(n) backward =  i = len(forward) - 1 while i >= 0: backward.append(forward[i]) i -= 1 backward = "".join(backward) if backward == forward: return True else: return False
How would one go about solving such a problem without using string conversion?