0
M = [[0, 0, 0, 1, 0, 0, 0],[0, 1, 0, 0, 0, 0, 0],[0, 1, 0, 0, 1, 0, 0],[0, 0, 1, 0, 0, 0, 0]]
print(M)
print(M[:])
print(M[:][:])
A=M[:][:]
B=[]
for ligne in M :
    B.append(ligne[:])
A[0][0] = 3
B[0][0] = 4
print(M)
print(A)
print(B)

You notice that A is not a separated duplicate of the value of M, because of the references changing A will change M too. So here is my second question : Can I create a duplicate of M without making a loop by hand like I did for B ?

LMT-PhD
  • 131
  • 3

0 Answers0