3 ms·
If iterating over a list, try iterating backwards. That way you can delete items from the list without effect on iterator position. This doesn't work on dicts,
by conesus 16y ago
If iterating over a list, try iterating backwards. That way you can delete items from the list without effect on iterator position. This doesn't work on dicts, of course, but this way you can delete in-place without creating a copy data structure.