Python Deleting Half The Elements In A List After Iterating Through It
I've been completely stumped on this one: I have the following python code: def remove(self, widgets): for widget in widgets: widget_found = False for widget_si
Solution 1:
... it skips every other element.
That's because you keep deleting them, shortening the list by 1. And then you move on to the next index. Either work backwards, or iterate over a copy of the list.
Post a Comment for "Python Deleting Half The Elements In A List After Iterating Through It"