N = 10
# input the number of columns
M = 10
# initializing the matrix
res = [ [ i*j for i in range(N) ] for j in range(M) ]
clash(i,j)=0
# printing in multiple lines
print("Multiline representation")
for i in range(N):
for j in range(M):
#matrix.append(["0"]*100)
print(res[i][j] ,end =" ")
print("")
存在一个错误,显示无法在clash(i,j)=0时分配到函数调用。因此,我真的需要帮助!
2条答案
按热度按时间wh6knrhe1#
也许通过创建列表?
matrix = [[0] * 10] * 10
形象1u4esq0p2#
我相信numpy更适合这样做
编辑:要设置值,请使用: