Apr-24-2017, 06:47 PM
I think the easy solution is to just iterate over a copy of the list, ie:
for x in some_list[:]:
, but then if the list is large (or is a generator and doesn't exist fully yet), that could just eat memory. Maybe for x in (item for item in some_list):
? That way you can modify the original list, without changing how you iterate. Could make for confusing results sometimes, though.