g is a list of list, I use it as a 2d array. But when I assign values to g[i][j], it doesn't work.
Here is my code.
m=3
n=4
g=[[0]*n]*m
for i in range(m):
for j in range(n):
g[i][j]=i
print(g[i][j])
print(g)
the output is
0
0
0
0
1
1
1
1
2
2
2
2
[[2, 2, 2, 2], [2, 2, 2, 2], [2, 2, 2, 2]]