[BangPypers] How for and list.remove() works

Kushal Das kushaldas at gmail.com
Wed Jul 9 17:35:40 CEST 2008


On Wed, Jul 9, 2008 at 8:47 PM, Kushal Das <kushaldas at gmail.com> wrote:
> Hi all,
>
>>>> a = [12, 12, 1321, 34, 23, 12, 34, 45, 77]
>>>> for x in a:
> ...   if x == 12:
> ...     a.remove(x)
>>>> a
> [1321, 34, 23, 12, 34, 45, 77]
>
> Can any one explain me how the remove works and how it is effecting the for
> loop.
>
Only think that comes in my mind is in memory change. Is that the reason ?

Kushal
-- 
http://fedoraproject.org
http://kushaldas.in
http://badvista.org
http://noooxml.org


More information about the BangPypers mailing list