def isPalindrome(word):
n1 = word
n2 = word[::-1]
if n1 == n2 :
return True
else:
return False
Run Code Online (Sandbox Code Playgroud)
我试过这个,但得到像Traceback一样的错误(最近一次调用最后一次):
File "Code", line 3, in isPalindrome
TypeError: 'int' object has no attribute '__getitem__'.
Run Code Online (Sandbox Code Playgroud)
如何处理数字?
python ×1