> Look at this -- from Python 2.5.1: > > >>> a = [1, 2, 3, 4, 5] > >>> for x in a: > ... if x == 3: > ... a.remove(x) > ... print x
Well ... you could use: >>> for i in range(len(a)-1, -1, -1): ... print a[i] ... if a[i] == 3: del a[i] ... 5 4 3 2 1 >>> print a [1, 2, 4, 5] Bye. -- http://mail.python.org/mailman/listinfo/python-list