compare list

Richie Hindle richie at entrian.com
Tue Nov 15 06:55:23 EST 2005


Ben,

> But the logic output is wrong.
> from sets import Set as set
> lisA=[1,2,5,9]
> lisB=[9,5,0,2]
> lisC=[9,5,0,1]
> def two(sequence1, sequence2):
>     set1, set2 = set(sequence1), set(sequence2)
>     return len(set1.intersection(set2)) == 2
> print two(lisA,lisB)
> False(should be true!)

Slow down.  The intersection of A and B is [2, 5, 9].

-- 
Richie Hindle
richie at entrian.com




More information about the Python-list mailing list