list comprehention

Mathijs q.q at q
Mon Jan 23 12:54:18 EST 2006


Op 19 jan 2006 vond "Paddy" <paddy3118 at netscape.net>: 
>>>> answer = [ val for val in set(ref) for x in
>>>> range(min(lst.count(val), ref.count(val)))] answer
> [2, 2, 4]

I don't think it's correct. Your algoritm with the ref and lst below gives 
3 as answer. The answer should have been 2 (1,3).

ref=[3, 3, 1, 1, 3]
lst=[5, 1, 4, 5, 3]




More information about the Python-list mailing list