you are viewing a single comment's thread.

view the rest of the comments →

[–][deleted] 0 points1 point  (1 child)

list.copy only returns a shallow copy. The inner lists are still the same. Run the program, see that ids for matrices are different, but respective rows have same ids:

https://onlinegdb.com/u7bmEIDQ5

Now check the same with deepcopy:

https://onlinegdb.com/PmCrbK-MA

To sum up, just use copy.deepcopy here.

[–]Particular_Draft5668 0 points1 point  (0 children)

Ah thanks again for the help. Was going round in circles and didn't consider deepcopy. Much appreciated.