自己的解法
class Solution:
def isPalindrome(self, x: int) -> bool:
if x < 0:
return False
length = len(str(x))
if x < 10:
return True
if length % 2 == 0:
if str(x)[0: length // 2] == str(x)[length - 1 : length // 2 - 1: -1]:
return True
return False
if length % 2 != 0:
if str(x)[0: length // 2 + 1] == str(x)[length - 1 : length // 2 - 1: -1]:
return True
return False