How does `L[:]` build a brand-new list object — and let you rewrite a list in place by cloning it, clearing it, and refilling it?
Short drills on what this video just taught. Write the code, run the checks, and reveal the answer only if you are stuck.
original holds [4, 5, 6]. Build a genuine copy of it and assign that copy to clone, then set the copy's first element to 99.
When you are done, original must still hold [4, 5, 6].
The slice clone Lnew = L[:]
Write the clone of Loriginal = [4, 5, 6], draw the two separate list objects with their two names, and record what each holds after one of them is changed.
Clone, clear, append back
Write remove_all as Lnew = L[:], then L.clear(), then for n in Lnew: if n != e: L.append(n), and trace it on [1, 2, 1, 2] with e = 1.
A mutating function with nothing to return
Record that the call remove_all(Lin, 1) is written without saving a return value, and print Lin afterwards to show the contents the caller now sees.