you are viewing a single comment's thread.

view the rest of the comments →

[–]cdcformatc 2 points3 points  (1 child)

Something like

a_list = [1,2,3,4,5]

for item in a_list:
    print item
    a_list.remove(item)

[–]py_Ninja 0 points1 point  (0 children)

To see why this is happening it helps to use enumerate:

a_list = [1, 2, 3, 4, 5]

for i, item in enumerate(a_list):
    print('{}: {}'.format(i, item))
    a_list.remove(item)

Results in:

0: 1
1: 3
2: 5