Converting a set into list

TheSaint nobody at nowhere.net.no
Sun May 15 11:56:58 EDT 2011


SigmundV wrote:

> I think the OP wants to find the intersection of two lists.
> list(set(list1) & set(list2)) is indeed one way to achieve this. [i
> for i in list1 if i in list2] is another one

Exactly. I was confused on that I wasn't able to have a list in return.
The set intersection is the smartest result better than a "for" loop or a 
comprehension list.
Infact the operatin loops are compiled into python, therfore they are the 
fastest.
-- 
goto /dev/null



More information about the Python-list mailing list