Reputation: 15104
Please take a look at the following snippet from ipython:
In [122]: len(netean)
Out[122]: 150
In [123]: len(nwrongpea)
Out[123]: 100
In [124]: len(set.intersection(set(nwrongpea), set(netean)))
Out[124]: 8
In [125]: len(set(nwrongpea) - set(netean))
Out[125]: 90
In [126]: len(set(netean) - set(nwrongpea))
Out[126]: 142
I am going crazy - since these two lists have the 8 elements in common (based on what intersection answers), how is it possible that [125] returns 90 ? Shouldn't that be 92 ?
Have I forgotten something from set theory ?
Thanks !
Upvotes: 2
Views: 236
Reputation: 7088
It looks like one(or two) of this collections have some duplicate elements. So creating sets from them gives you sets with less number of elements..
Try len(set(natean)) + len(set(nwrongpea))
and you'll see.
Upvotes: 10