0
我在Python 3中制作了一个程序,它测试一个数字是否是回文。显然它没有完成,但是当我尝试运行它时:TypeError,回文测试(Python 3.x)
#!/usr/bin/env python
def testforpalin():
i = 101
lop = list(str(i))
print(lop)
len(lop)
if lop[0] == lop[len-1]:
print("hi")
testforpalin()
TypeError: unsupported operand type(s) for -: 'builtin_function_or_method' and 'int'
我得到那个错误。我该如何解决?
在该行if lop[0] == lop[len-1]:
你有len-1
其中len
是给你的字符串的长度(因此错误的函数