x = int(input())
if x<0 and (x%10 == 0 and x !=0):
print("false")
rev = 0
while x>0:
rev = rev*10 + x%10
x = x // 10
if rev == x:
print("true")
else:
print("false")
Since the reversed number is the same as entered one, the condition rev == x
should return true but it's giving the opposite. What am I doing wrong?
Edit 1: converting to string is not allowed
Edit 2: I see now.