list comprehention

Mathijs q at
Mon Jan 23 18:41:55 CET 2006

Op 19 jan 2006 vond "markscala at" :

> 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