Nov-16-2019, 05:25 PM
(Nov-16-2019, 04:52 PM)albufork Wrote: I made list2 a copy of list1.Actually
list1
and list2
point to same object. the assignment just copies the reference to the list, not the actual list, so both list1
and list2
refer to the same list after the assignment.to make a copy of list use
list2 = list1.copy()or
list2 = list1[:]you can also use
copy.copy()
and copy.deepcopy()
from copy module
If you can't explain it to a six year old, you don't understand it yourself, Albert Einstein
How to Ask Questions The Smart Way: link and another link
Create MCV example
Debug small programs
How to Ask Questions The Smart Way: link and another link
Create MCV example
Debug small programs