[Mathijs] > Example2: > ref=[2, 2, 4, 1, 1] > list=[2, 2, 5, 2, 4] > solution: 3 (note that only the first two 2's count, the third 2 in the > list should not be counted)
[Morten Vold] > May I suggest another one-liner: > > len(set(ref).intersection(lis)) > > I have no idea how this scales/performs compared to the other > suggestions you've received, but I find it immediately comprehensible. >>> len(set([2, 2, 4, 1, 1]).intersection([2, 2, 5, 2, 4])) 2 Close, but no cigar. Peter -- http://mail.python.org/mailman/listinfo/python-list