On 5 Sep 2006 16:05:36 -0700, bayerj <[EMAIL PROTECTED]> wrote:
> > I'm going to assume that it's supposed to work like this, but could
> > someone tell me the reasoning behind it?  I.E. why is 3 skipped?
>
> Because:
>
> >>> alist[2]
> 3
>
> You are removing the third item, not the second.
>

Actually,  he's removing 2 from the list,   but then the length of the
list shrinks by 1 and iteration stops.

The example would have been better if alist = ['a','b','c'] and 'b' was removed.

 L.remove(value) -- remove first occurrence of value

you were possibly  thinking of alist.pop(2),  which removes the item
alist[2] from alist

HTH :)


-- 

Tim Williams
-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to