June 2017
Beginner
352 pages
8h 39m
English
To find all the people with blond hair and blue eyes, we can use the intersection() method:
>>> blue_eyes.intersection(blond_hair){'Amelia', 'Jack', 'Harry'}
Which collects together only the elements which are present in both sets. This is also commutative:
>>> blue_eyes.intersection(blond_hair) == blond_hair.intersection(blue_eyes)True
Read now
Unlock full access