3 ms·
This technique is also useful for iterating over a list and conditionally removing items. If you don't slice it you are changing the list as your iterate over i
by swanson 15y ago
This technique is also useful for iterating over a list and conditionally removing items. If you don't slice it you are changing the list as your iterate over it and you get unexpected results (like skipping items).
Or you could just use list comprehensions :)