Le 10/02/12 21:48, Thomas Philips a écrit :
Thanks for the insight. I saw the behavious as soon as I extended x
with a bunch of 0's

x = list(range(10))
x.extend([0]*10)
x
[0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]
for i in reversed(x):
	if i % 2 == 0:
		x.remove(i)

x
[1, 3, 5, 7, 9]

x = list(range(10))
x.extend([0]*10)
x
[0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]
for i in x:
	if i % 2 == 0:
		x.remove(i)


x
[1, 3, 5, 7, 9, 0, 0, 0, 0, 0]
Not a good example, with reversed(), you're not iterating on the list x but on an another list.

More precisely a 'listreverseiterator object.

--
Vincent V.V.
Oqapy . Qarte+7 . PaQager
-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to