我试图运行这段代码,但它显示了一个错误:
def shoot(aliens):
s=[0]*1000
s[0]=0
s[1]=1
num=len(aliens)
b=[[0 for m in range(1000)] for n in range(1000)]
for j in xrange(2,num):
for i in xrange(0,j):
b[j][i]=s[i]+min(int(aliens[j]),f[j-i]) ##Error here
s[j]=max(b)
和错误:
Traceback (most recent call last):
File "module1.py", line 67, in <module>
print shoot(line)
File "module1.py", line 26, in shoot
b[j][i]=s[i]+min(int(aliens[j]),f[j-i])
TypeError: can only concatenate list (not "int") to list
请帮忙!
编辑:添加了更多代码。s、aliens 和 f 是其他数组。我试图将结果保存到二维数组,但它显示了该错误。