I have main dictionary.
mainDict = {'count': 10, 'a': {'abc': {'additional': 0, 'missing': 0, 'changed': 0}}}
Now i have new dictionary with same keys as in mainDict, called this dictionary as b with different values.
b = {'count': 20, 'a': {'abc': {'additional': 10, 'missing': 10, 'changed': 10}}}
I want to update(addition operation) the values of keys in main dictionary so i do..
mainDict = {'count': mainDict['count'] + b['count'], 'a': }
I am stuck at updating values of key a. If i use mainDict.update(b) then it will replace previous values. Any efficient solution??
The final output required is:
mainDict = {'count': 30, 'a': {'abc': {'additional': 10, 'missing': 10, 'changed': 10}}}
Thanks
1 Answer