P
Phil Schmidt
The following example works fine (Python 2.3), but is it always safe
to modify a list that is being iterated in a loop, regardless of the
actual contents of the list x? If not, what's a better (safe) way to
do it?
Thanks!
x.remove(t)
[{'f': 1}, {'f': 3}]
to modify a list that is being iterated in a loop, regardless of the
actual contents of the list x? If not, what's a better (safe) way to
do it?
Thanks!
if t['f'] == 9:x=[{'f':9},{'f':1},{1:3,'f':9},{'f':3}]
for t in x:
x.remove(t)
[{'f': 1}, {'f': 3}]