I currently have a 2d matrix
matrix = [['.', '.', '.', '.', '.', '.'],
['.', '.', '.', '.', '.', '.'],
['.', '.', '.', '.', '.', '.'],
['.', '.', '.', 'O', 'O', 'O'],
['.', '.', '.', 'O', '.', '.'],
['.', '.', '.', 'O', 'O', '.']]
And I've assigned copy = matrix
to make a copy of the matrix.
However, I ran into a bug where when I modify copy[]
, it also modifies matrix[]
.
I found out that this is a side effect with aliasing and I need to create a deep copy of matrix[]
.
How do I create a deep copy of a 2d matrix without using imports?