I have multiple dicts/key-value pairs like this:
d1 = {key1: x1, key2: y1} d2 = {key1: x2, key2: y2}
I want the result to be a new di
If you only have d1 and d2,
from collections import defaultdict d = defaultdict(list) for a, b in d1.items() + d2.items(): d[a].append(b)