回文测试器给False表示11,但返回True表示121

问题描述

这是我的代码:

def isPalindrome(x):
    if x < 0 or (x % 10 == 0 and x != 0):
        return False
    rev = 0
    while x > rev:
        rev = (rev*10 + x % 10)
        x /= 10
    return x == rev or x == rev/10

x = 11
print(isPalindrome(x))

为什么此代码不能为所有正整数输入提供理想的结果?

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)