下面的程序给出了错误IndexError: list index out range
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但当我现在使用包含1000个值的newlist的相同程序时,它可以工作
newlist=[2,3,1,5,6,123,436,124,223.......,213]
# total 1000 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(1000):
for j in range(0,4):
print(i,j,emptylist[k])
k=k+1那么,为什么它不能处理5600个值,显示索引超出范围,但它能处理1000个值呢?
尝试使用Len of the list也不起作用
https://stackoverflow.com/questions/50777787
复制相似问题