pallas 发表于 2021-10-16 13:40:32

求助大佬这个关于 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
求助这个代码的错误(其他方法也可以,麻烦附上注释,谢谢!!)

pallas 发表于 2021-10-16 18:46:01

已解决
页: [1]
查看完整版本: 求助大佬这个关于 Palindrome Number (Python)的问题