In Python you often get problematic results if you modify a collection as you are iterating over it.
So we iterate over a copy, like
new_list =  for x in original_list: if ...: new_list.append(x) original_list[:] = new_list
In some situations you can just
original_list = new_list but obviously not if other things have references to
original_list, and if that variable isn’t from this scope you need a
nonlocal declaration to assign to it.
What if lists/sets/dicts had a function like
.popall() that removes and returns all items. You’d just be able to write:
for item in mylist.popall(): if ...: mylist.append(item)
It gets around the problem of modifying a collection while iterating over it while being a couple of lines shorter.
It’s a cheap operation. It could just hand ownership of the backing array over to a new collection object without touching even the reference counts of the items it contains. If I have this right it’s actually a little cheaper - it is skipping one incref and one decref per object vs the list code I have above.