0
爲什麼在我的數字列表上運行這個Python腳本時收到以下錯誤?操作數字列表 - Python
(其中,x = [1,2,3,4])
腳本:
x = []
for i,line in enumerate(sys.stdin):
if i == 1:
x = line.split()
x = list(map(int, x))
val = x[len(x)-1]
x.extend(val)
Traceback (most recent call last):
File "solution.py", line 13, in <module>
x.extend(val)
TypeError: 'int' object is not iterable