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

Klaus Meyer km-news1 at onlinehome.de
Sat Mar 1 19:37:03 CET 2003


Hi,

it is OK to change a list inside a for loop?
Example:

x=range(100)
for i in x:
    del x[-1]


Another Question:
How to remove a found element from a list in a for-loop?

x=["A", "B", "C", "D"]
for i in x:
	if i=="C": del x[this one, but how?]

-- 
Gruß - regards Klaus :-)




More information about the Python-list mailing list