I,m new in python and have a code like this in python 3.9:
a = [[0]*3]*3
a[0][0] = 1
print(a)
output: [[1,0,0],[1,0,0],[1,0,0]]
I thought that the output should be:
output: [[1,0,0],[0,0,0],[0,0,0]]
changing this line
a = [[0]*3]*3
to
a=[]
for i in range(3):
a.append([0]*3)
will solve the issue
could someone tell me where I am wrong please.