d1 = {'a': 1, 'b': 2, 'c': 3}
d2 = {'a': 2, 'b': 3, 'd': 4}
d3 = defaultdict(list)
for k, v in chain(list(d1.items()), list(d2.items())):
    d3[k].append(v)
for k, v in list(d3.items()):
    pass
Merging two dictionaries while keeping the original