提示:这里描述项目中遇到的问题:
a = []
b = [5,6,7,8]
for i,j in enumerate(b):
a[i] = j
# a.append(j)
print(a)
报错:IndexError: list assignment index out of range
a为空,没有索引
使用append()函数
a = []
b = [5,6,7,8]
for i,j in enumerate(b):
#a[i] = j
a.append(j)
print(a)
码字不易,谢谢点赞!!!
码字不易,谢谢点赞!!!
码字不易,谢谢点赞!!!