下面的程序给出错误索引器错误:列表索引超出范围
newlist=[2,3,1,5,6,123,436,124,223.......,213,213,213,56,2387567,3241,2136]
# total 5600 values seprated by commas in the above list
emptylist = []
for values in newlist:
convstr = str(values)
convstr = convstr.split(",")
emptylist.extend(convstr)
k=0
for i in range(5600):
for j in range(0,4):
print(i,j,emptylist[k])
k=k+1
但是当我使用同一个程序时,newlist包含1000个值,它就可以工作了
^{pr2}$所以,为什么它不能处理5600个值,这表明索引超出范围,但它使用1000个值?在
尝试使用列表的Len也不起作用
如果你有5600个元素的列表。将它们转换成字符串,而不增加其数量。您迭代5600次,在每次迭代中,您将
k
增加4倍,并使用k
-结果:index error索引到列表中相关问题 更多 >
编程相关推荐