Why does a loop that removes items from the list it is walking silently skip elements, with no error at all?
Short drills on what this video just taught. Write the code, run the checks, and reveal the answer only if you are stuck.
Here is the buggy pattern again, this time on a list of five 4s:
L = [4, 4, 4, 4, 4] e = 4 for elem in L: if elem == e: L.remove(e)
Work out by hand what L holds once this loop finishes — track the position counter yourself, pass by pass — and assign that list, written out as a list literal, to final_list.