title: Python function that returns the sum of values of two dicts
body: <p>What <code>function</code> should I make that takes a country identifier from the dictionaries below and returns the sum the values of two dictonaries with unequal length. Also, the dicts should be weighed differently (find info below). In case one of the dicts has no info on a specific country (e.g. dict y does not have any info about the USA), then only one value should be used (e.g. dict x does have info about the USA, thus the output of the function should be 12.1).  For example:</p>
  
  <p>Dictionary one:</p>
  
  <p><code>x = {'USA':12.1, 'AUS':11.2, 'IND':10.3}</code></p>
  
  <p>Dictionary two:</p>
  
  <p><code>y = {'AUS': 9.4, 'IND': 8.3}</code></p>
  
  <p>Summing up the criteria for the <code>function</code>:</p>
  
  <ul>
  <li>Input = a country identifier</li>
  <li>Output = sum of the values that belong to a country</li>
  <li>The values from each dict should have a different weight when calculating the sum. Dict Y gets weight 0.8. Dict X gets weight 0.2.</li>
  <li>The Function should be iterable as it will be  used in another function that sees into two -given- huge dictionaries.</li>
  </ul>
  
  <p>I tried the following code, but it doesn't work:</p>
  
  <p><code>def sum_dict_values(key):
      temp1 = (d.get(key, 0) for d in (x))
      temp2 = (d.get(key, 0) for d in (y))
      return sum(0.8*temp1, 0.2*temp2)</code></p>
  
  <p>When running</p>
  
  <p><code>sum_dict_values("USA")</code></p>
  
  <p>I get the error:</p>
  
  <p><code>TypeError: unsupported operand type(s) for *: 'float' and 'generator'</code></p>