求助大佬这个关于 Palindrome Number (Python)的问题
题目:Given an integer x, return true if x is palindrome integer.
An integer is a palindrome when it reads the same backward as forword.
代码:
num1 = input("请输入数字x:")
x = int(num1)
class Solution:
def isPalindrome(self, x: int) -> bool:
if x < 0: return False
str_x = str(x)
if len(str_x) == 1: return True
for t in range(int(len(str_x) / 2)):
if str_x != str_x[-1 - t]:
return False
return True
求助这个代码的错误(其他方法也可以,麻烦附上注释,谢谢!!) 已解决
页:
[1]