We have 3 dictionaries with same keys as dates and with different count values for each date.
Input :-
dict1 = {'01/03/22': 7, '02/03/22': 7, '03/03/22': 0, '04/03/22': 7}
dict2 = {'01/03/22': 5, '02/03/22': 1, '03/03/22': 0, '04/03/22': 1}
dict3 = {'01/03/22': 2, '02/03/22': 4, '03/03/22': 0, '04/03/22': 3}
Output :- The final output should be as below.
final_dict = {'01/03/22': 14, '02/03/22': 12, '03/03/22': 0, '04/03/22': 11}
I have tried it using Counter class but it has missed the key-value pair which has 0 count values for the items.
final_dict = dict(Counter(dict1) + Counter(dict2) + Counter(dict3))
It has given me output below:-
final_dict = {'01/03/22': 14, '02/03/22': 12, '04/03/22': 11}
So in above you can see we have missed key value pairs which has 0 counts but as part of request i need to have the values for each date.
Any suggestions?