it is clear what this code do:
>>> sw = ['go', 'bo'] >>> for cm in sw: ... if cm == 'bo': ... sw.remove(cm) ... >>> sw ['go']but when a list contains 4 'bo' items only 2 will be removed:
>>> sw = ['go', 'bo', 'bo', 'bo', 'bo'] >>> for cm in sw: ... if cm == 'bo': ... sw.remove(cm) ... >>> sw ['go', 'bo', 'bo'] >>>why not all 'bo' items are removed?