I have 2 dicts as follows:
d1 = {a:2, b:4}
d2 = {a:13, b:3, c:5}
How to merge these two and add 0 if one key is empty?
The result should be
= {a:[2,13], b:[4,3], c:[0,5]}
I tried to use this
d1 = {'a':2, 'b':4}
d2 = {'a':13, 'b':3, 'c':5}
dd = defaultdict(list)
for d in (d1, d2):
for key, value in d.items():
dd[key].append(value)
but I don't know how to add 0, I'm really new to programming.