0

I have 2 dictionaries of words and the frequencies at which they are found in 2 txt files. I want to combine these 2 dictionaries into a new one but I want the frequencies to be added together on instances when a duplicate is found.

For instance,

dict1 = {'a':1, 'b':2, 'c':3}
dict2 = {'a':3, 'g':1, 'c':4}

When combined into a new dictionary, I want dict3 to be {'a':4, 'b':2, 'c':7, 'g':1}

I'm not really sure how to do this.

Ams6483
  • 3
  • 2

0 Answers0