Why is `pop()` the only one of `del`, `pop`, and `remove` that hands the removed value back to you?
Short drills on what this video just taught. Write the code, run the checks, and reveal the answer only if you are stuck.
readings holds seven sensor readings. Delete the single reading that sits at the middle position of the row, leaving the other six untouched and in their original order. Change the existing list in place rather than typing out a new one, so the result stays in readings.
(Hint: del keys on position, and indices start at 0.)
Deleting by index, from the end, by value
Write del L[index], L.pop() and L.remove(element) side by side with what each one targets, noting that remove takes only the first match found from index 0.
Which of the three hands back a value
Record that L.pop() returns the dropped element for saving in a variable, that assigning from L.remove(e) gives None, and that y = del L[0] is a SyntaxError.
A chain of deletions on one list
Trace L = [1, 2, 3, 6, 3, 7, 0] through L.remove(2), L.remove(3), del L[1] and L.pop(), writing the full contents of L after each call.
remove_all as a two-line while loop
Write while e in L: L.remove(e) and state the contents it leaves behind for an input list holding several copies of e.