0

So I'm trying to create a back up of a list but when I want to modify the backup variable, both are being modified.

a = [[1, 2], [1, 2]]
b = a
del a[-1]

print(a)
print(b)

Output:

[[1, 2]]
[[1, 2]]

What can I do so my output looks like this:

[[1, 2],[1, 2]
[[1, 2]
martineau
  • 119,623
  • 25
  • 170
  • 301

0 Answers0