Oct-04-2020, 06:16 AM
# a dict value that is a set d['Cubs'] = set() # adding members to the set d['Cubs'].add(1907) d['Cubs'].add(1908) d['Cubs'].add(2016) # display contents of the set print(d['Cubs'])This might be a nice place to use a defaultdict. If it defaults to a set, you don't have to create the set for each winner before adding to it.
from collections import defaultdict d = defaultdict(set) d['White Sox'].add(1906) d['Cubs'].add(1907) print(d['Cubs'])