【发布时间】:2022-01-05 17:36:13
【问题描述】:
rows = 7
cols = 6
mat = []
for i in range(cols):
col = []
for j in range(rows):
col.append(0)
mat.append(col)
for i in range(cols):
for j in range(rows):
print(mat[j])
print('\n')
为什么会有 //IndexError: list index out of range// 错误?
【问题讨论】:
-
mat[i]有效,或mat[i][j]但不是mat[j]。
标签: python list index-error