0

I want to copy a list and make changes to the copy without affecting the original list.

a = [[2,3],[4,5]]
b = list(a)

print(b)

del b[0][0]

print(b)
print(a)

I was expecting a = [[2, 3], [4, 5]] in the end.

However, the output was

[[2, 3], [4, 5]]
[[3], [4, 5]]
[[3], [4, 5]]

How can I fix this?

Michael M.
  • 10,486
  • 9
  • 18
  • 34

0 Answers0