I'm trying to copy a matrix and modify it without modifying the original one
I know that I can't just make
new = old
otherwise, python will not copy the list referenced by new. We just created a new tag old and attached it to the list pointed by new. I've tried methods such as
new = list(old)
new = old[:]
new = old.copy()
and even so, it doesn't work.
the piece of my code where it happens is this:
mat = []
my_inputs()
for a in range(n):
gen = mat[:]
for l in range(len(gen)):
for c in range(len(gen[0])):
if mat[l][c] == " " and cna([l, c], mat) == 3:
gen[l][c] = "@"
elif mat[l][c] == "@" and cna([l, c], mat) >= 4:
gen[l][c] = " "
By the way those lists are actually vectors.