Section 10.12 Cloning Lists
If we want to modify a list and also keep a copy of the original, we need to be able to make a copy of the list itself, not just the reference. This process is sometimes called cloning, to avoid the ambiguity of the word copy.
The easiest way to clone a list is to use the slice operator.
Taking any slice of
acreates a new list. In this case the slice happens to consist of the whole list.
Now we are free to make changes to
bwithout worrying about
a. Again, we can clearly see in codelens that
bare entirely different list objects.
You have attempted of activities on this page.