defisPalindrome(x:int)->bool:
lst =list(str(x))# L,R为字符串的左、右索引
L, R =0,len(lst)-1while L <= R:if lst[L]!= lst[R]:returnFalse# 当lst[L]等于lst[R]时,左索引值+1,右索引值-1
L +=1
R -=1returnTrue
defisPalindrome(x:int):
temp = x
res =0# 当值小于0时,直接返回if x <0:returnFalseelif x ==0:returnTrue# L为输入整型数字的长度
L =int(math.log(x,10))+1for i inrange(L):# new_int为每次数字的末尾数字
new_int = x %10# 反转,拼接,累加,成为一个新的整型数字,最后与原串比较
res += new_int *(10**(L -1- i))# 循环一次后,将原数字缩小10倍【剔除末尾数字】
x = x //10if res == temp:returnTrueelse:returnFalse