Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/templates/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python '__leet代码66的测试用例上的getitem_uuu` attribute错误。另外一个很难通过_Python_Python 3.x - Fatal编程技术网

Python '__leet代码66的测试用例上的getitem_uuu` attribute错误。另外一个很难通过

Python '__leet代码66的测试用例上的getitem_uuu` attribute错误。另外一个很难通过,python,python-3.x,Python,Python 3.x,我无法通过一个测试用例,但我不知道我的程序出了什么问题 接受案例 Your input [1,2,3] Output [1,2,4] Expected [1,2,4] input [9] expected output [1,0] TypeError: 'int' object has no attribute '__getitem__` Line 16 in plusOne(Solution.py) Line 41 in _driver(Solution.py) Line 53 in &l

我无法通过一个测试用例,但我不知道我的程序出了什么问题

接受案例

Your input
[1,2,3]
Output
[1,2,4]
Expected
[1,2,4]
input
[9]
expected output
[1,0]
TypeError: 'int' object has no attribute '__getitem__`
Line 16 in plusOne(Solution.py)
Line 41 in _driver(Solution.py)
Line 53 in <module>(Solution.py)
i = 9876
s = str(i)
print(s[-1])
# 6

print(s[-3])
# 8
不接受案例

Your input
[1,2,3]
Output
[1,2,4]
Expected
[1,2,4]
input
[9]
expected output
[1,0]
TypeError: 'int' object has no attribute '__getitem__`
Line 16 in plusOne(Solution.py)
Line 41 in _driver(Solution.py)
Line 53 in <module>(Solution.py)
i = 9876
s = str(i)
print(s[-1])
# 6

print(s[-3])
# 8
错误消息

Your input
[1,2,3]
Output
[1,2,4]
Expected
[1,2,4]
input
[9]
expected output
[1,0]
TypeError: 'int' object has no attribute '__getitem__`
Line 16 in plusOne(Solution.py)
Line 41 in _driver(Solution.py)
Line 53 in <module>(Solution.py)
i = 9876
s = str(i)
print(s[-1])
# 6

print(s[-3])
# 8
我试图做什么来确保错误消息

Your input
[1,2,3]
Output
[1,2,4]
Expected
[1,2,4]
input
[9]
expected output
[1,0]
TypeError: 'int' object has no attribute '__getitem__`
Line 16 in plusOne(Solution.py)
Line 41 in _driver(Solution.py)
Line 53 in <module>(Solution.py)
i = 9876
s = str(i)
print(s[-1])
# 6

print(s[-3])
# 8

在语句
中返回数字[:len(digits)-1]+nums
,在哪里定义了
数字?你的意思是数字吗?@Booboo是的。我修复了它,但仍然存在错误。在
nums.append(last_num[-(len(str(last_num)))+I])
行中,为什么要索引
last_num
?如果是不同的错误,请更改您的问题并告诉世界错误是什么。如果是相同的错误,请在函数开始处打印出
数字
,以查看传递的内容;它可能不是一个列表。