Function to remove elements from a list working, but Python Hangs :((

Girish Sahani girish at cse.iitb.ac.in
Mon Jun 12 07:10:00 EDT 2006


> I guess it's already the case with lst = [ e for e in lst if e in pairs ]
>
>
> In [1]: lst = (1,2,3,4)
>
> In [2]: pairs=(5,)
>
> In [3]: lst=[e for e in lst if e in pairs]
>
> In [4]: lst
> Out[4]: []
Yes its working. I realized that i was giving an input which didnt satisfy
the condition.
Now if you could please check out this new problem i'm facing,related to
this.In my code,l4 is a list of lists, and these lists contain such pairs.
e.g. l4 =
[[[4,2],[4,7],[4,10],[4,12],[9,2],[9,7],[9,10],[9,12],[11,2],[11,10]],[[1,2],[3,5],[7,8]]]
which is a list of 2 lists (having 13 pairs)
Now when l4 has 50 pairs, and i run the code, python just hangs, and i'm
quite sure its because of this. Is there any way to rectify this???



>
>
>
> --
> _____________
>
> Maric Michaud
> _____________
>
> Aristote - www.aristote.info
> 3 place des tapis
> 69004 Lyon
> Tel: +33 426 880 097
> --
> http://mail.python.org/mailman/listinfo/python-list
>




More information about the Python-list mailing list