I have the following three dictionaries:
d1 = {'python':15, 'java':2,'c#':3}
d2 = {'go':30,'c#':4, 'java':10,}
d3 = {'python':2,'ruby':7}
I have used the following code to merge and sum all values of the same keys.
d={}
for mydict in d1,d2,d3:
for key in mydict:
d[key] = d.get(key,0) + mydict[key]
print(d)
But I am not able to change this code into a comprehension.
I have already done it using collection.Counter and Itertools.chain() method.