Combine dictionary values
Combines two or more dictionaries, creating a list of values for each key.
- Create a new
collections.defaultdict
withlist
as the default value for each key and loop overdicts
. - Use
dict.append()
to map the values of the dictionary to keys. - Use
dict()
to convert thecollections.defaultdict
to a regular dictionary.