- set
- intersection
set intersection
examples/sets/intersection.py
english = set(['door', 'car', 'lunar', 'era']) spanish = set(['era', 'lunar', 'hola']) print('english: ', english) print('spanish: ', spanish) both = english.intersection(spanish) print(both)
- intersection returns the elements that are in both sets.
english: {'car', 'lunar', 'era', 'door'} spanish: {'lunar', 'era', 'hola'} {'lunar', 'era'}