Python: How can I edit a copy of a list independently? -
this question has answer here:
- copying 2d lists in python 2 answers
i have nested list a
. let list b=list a
. when try edit list b changing of elements using b[1][2]=2
, list a[1][2]
gets changed too.
why happen?
because assigning reference, list b pointing list a. have use copy of list. answered here:
Comments
Post a Comment