0

i'm encountering avery strange issue when programming in python 3.7:

A = [[1,2],[0,3]]
B = A[:][:]   # creates a copy of A to work with, without modify A
del B[0]

This works,well,as B becomes [[0,3]] and A is still [[1,2],[0,3]]. However, if I try this :

A = [[1,2],[0,3]]
B = A[:][:]     # creates a copy of A to work with, without modify A
del B[0][1]

B becomes [[1], [0, 3]], but A also turns into [[1], [0, 3]] ! I can't understand this behaviour,could you explain me what's happening there ?

Aran-Fey
  • 39,665
  • 11
  • 104
  • 149
EinderJam
  • 417
  • 1
  • 6
  • 20

0 Answers0