I just started learning Python and I encountered this problem:
a = [0, 1]
b = [a]
print(a, b)
a.pop()
print(a, b)
Result:
[0, 1] [[0, 1]]
[0] [[0]]
Why does this happen and how do I avoid it? I want b = [0, 1]. As far as I understood, the b[0] was linked to a so I used b[a.copy()]
. Thanks guys.