python said : "1, 2, 3, 6, 7, manbo !"

Miki Tebeka miki.tebeka at zoran.com
Thu Jan 22 02:35:19 EST 2004


Hello Rodrigo,
> >>> a = range(8)
> >>> for b in a:
> 	if b == 4:
> 		a.remove(b)
> 	else:
> 		print b
try:
a = range(8)
for b in list(a): # Iterate over a shallow copy
    if b == 4:
        a.remove(b)
    else:
        print b
0
1
2
3
5
6
7

HTH.
Miki



More information about the Python-list mailing list