list comprehention

Mathijs q at q.nl
Mon Jan 23 12:41:55 EST 2006


Op 19 jan 2006 vond "markscala at gmail.com" :

> another approach:
> 
> ref = [2,2,4,1,1]
> lis = [2,2,5,2,4]
> 
> len([ref.pop(ref.index(x)) for x in lis if x in ref])
> 

This is the type of solution I was hoping to see: one-liners, with no use 
of local variables. As Tim Chase already wrote, it has only one less 
elegant side: it alters the original ref list.

Thanks for your suggestion.



More information about the Python-list mailing list