title: Python program to combine two dictionary adding values for common keys
body: <p>I have two dictionaries and I need to combine them. I need to sum the values of similar keys and the different keys leave them without sum. </p>
  
  <p>These are the two dictionaries:</p>
  
  <pre><code>d1 = {'a': 100, 'b': 200, 'c':300}
  d2 = {'a': 300, 'b': 200, 'd':400}
  </code></pre>
  
  <p>The expected results:</p>
  
  <pre><code>d3= {'b': 400, 'd': 400, 'a': 400, 'c': 300}
  </code></pre>
  
  <p>I have successfully made the sum and added them to this third dictionary, but I couldn't know, how to add the different values. </p>
  
  <p>My try</p>
  
  <pre><code>d1 = {'a': 100, 'b': 200, 'c':300}
  d2 = {'a': 300, 'b': 200, 'd':400}
  d3 = {}
  
  for i, j in d1.items():
      for x, y in d2.items():
          if i == x:
              d3[i]=(j+y)
  
  
  print(d3)
  
  
  My results = {'a': 400, 'b': 400}
  </code></pre>