On Jan 29, 10:59 pm, Paul Hankin <[EMAIL PROTECTED]> wrote:
> If I really had to modify it in place (and the condition wasn't really
> x == 99), how about:
> bad_indices = [i for i, x in enumerate(a) if x == 99]
> for bad_index in reversed(bad_indices):
>     del a[bad_index]

Or one could use the trick of counting from the right (untested):

n = len(a)
for i, x in enumerate(a):
    if x == 99: del a[i-n]

--
Arnaud
-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to