Why does my list always copy like "mirroring" another variable though I already use "copy.deepcopy(var)" instead of "using var.copy()"?
Python Code:
import copy
after = [[[2,1]]]
for j in range(3):
before = copy.deepcopy(after)
after.clear()
cond = "false"
for i in range(len(before)):
after.append(before[i])
a_len = len(after)-1
after[a_len].append([1,5])
print(before)
print(after)
print("____")
Expected output:
[[[2, 1]]]
[[[2, 1], [1, 5]]]
____
[[[2, 1], [1, 5]]]
[[[2, 1], [1, 5], [1, 5]]]
____
[[[2, 1], [1, 5], [1, 5]]]
[[[2, 1], [1, 5], [1, 5], [1, 5]]]
Terminal output (now):
[[[2, 1], [1, 5]]]
[[[2, 1], [1, 5]]]
___
[[[2, 1], [1, 5], [1, 5]]]
[[[2, 1], [1, 5], [1, 5]]]
___
[[[2, 1], [1, 5], [1, 5], [1, 5]]]
[[[2, 1], [1, 5], [1, 5], [1, 5]]]