for i in list - change a list inside a for loop?

Dag f98dawa at dd.chalmers.se
Tue Mar 4 10:35:34 EST 2003


On Sat, 01 Mar 2003 19:53:50 +0100, Irmen de Jong <irmen at -NOSPAM-REMOVETHIS-xs4all.nl> wrote:
> 
> Just write:
> 
> 	x.remove("C")
> 
> if you need to remove "C" from the list x.

Note that this will only remove the first "C" in the list.  If you want
to remove all of them you have to do something along the lines of
	while 1:
	    try:
    	        a.remove("C")
	    except:
	        break

Dag	




More information about the Python-list mailing list