Message377700
You will get the same behavior for lists:
>>> a = [1, 2, 3]
>>> for x in a:
... if x == 1:
... a.remove(x)
... print(x)
...
1
3
Lists are iterated by index. First you get an item at index 0, then at index 1, etc, to the end of the list. Initially the list is [1, 2, 3]. After removing 1 at the first iteration it becomes [2, 3], and at the next iteration you get an item at index 1 which is 3. |
|
Date |
User |
Action |
Args |
2020-09-30 14:43:11 | serhiy.storchaka | set | recipients:
+ serhiy.storchaka, eric.smith, WoodyWoo |
2020-09-30 14:43:11 | serhiy.storchaka | set | messageid: <1601476991.17.0.492597160685.issue41892@roundup.psfhosted.org> |
2020-09-30 14:43:11 | serhiy.storchaka | link | issue41892 messages |
2020-09-30 14:43:11 | serhiy.storchaka | create | |
|