I have many dicts, I'm giving 2 for this example:
dict1={'green': 3, 'yellow': 5, 'blue': 1}
dict2={'green': 5, 'yellow': 1, 'blue': 3, 'purple': 10}
I've been trying to find a way to add the 2 dicts so i can have updated values(sum) for existing keys, and added up keys and values for non-existant ones.
Results:
results = {'green': 8, 'yellow': 6, 'blue': 4, 'purple': 10}
I tried dict1.update(dict2)
but as you know , I've only got a dictionary with updated values, not summed up.
Any ways to achieve this?
UPDATE:
Solved : Actually collections.Counter did the trick ... Thanks