4 ms·
I thought it seemed odd that Python supported the AND operator on lists, but it doesn't. You do need to convert to a set first, e.g. [1,2,3] & [1,2] gives
by joshvm 11y ago
I thought it seemed odd that Python supported the AND operator on lists, but it doesn't.
You do need to convert to a set first, e.g.
[1,2,3] & [1,2]
gives a TypeError, while
set([1,2,3]) & set([1,2])
gives set([1,2]) as expected.