Message164220
This happens because you modify the list while iterating over it, which makes the loop not work as you expect. Essentially, when you remove the item that's currently being pointed to, the loop skips over the next item.
An idiomatic way to remove items from a list is to use a list comprehension to create a new list without the unwanted items:
item_list = ["apple", "bananna", "blueberry", "coconut"]
new_list = [item for item in item_list if not item.startswith('b')] |
|
Date |
User |
Action |
Args |
2012-06-28 05:06:28 | petri.lehtinen | set | recipients:
+ petri.lehtinen, Eklutna |
2012-06-28 05:06:27 | petri.lehtinen | set | messageid: <1340859987.88.0.0830426556627.issue15214@psf.upfronthosting.co.za> |
2012-06-28 05:06:27 | petri.lehtinen | link | issue15214 messages |
2012-06-28 05:06:26 | petri.lehtinen | create | |
|