def isPalindrome(x: int) -> bool:
if x < 0 or (x % 10 == 0 and x != 0):
return False
revertedNumber = 0
while x > revertedNumber:
revertedNumber = revertedNumber * 10 + x % 10
x //= 10
return x == revertedNumber or x == revertedNumber // 10
if name == “main”:
x = 17899871
result = isPalindrome(x)
print( result )