title: Python sum dict values based on keys
body: <p>How to sum values from dict where values are string. I mean how to sum values where multiply key is same in dictionary.</p>
  <h1>dict</h1>
  <pre><code>values = [
      {
          &quot;rashod&quot;: 0,
          &quot;prihod&quot;: 230.0,
          &quot;prod_name&quot;: &quot;r&quot;,
          &quot;prod_hola&quot;: &quot;t&quot;
      },
      {
          &quot;rashod&quot;: 0,
          &quot;prihod&quot;: 230.0,
          &quot;prod_name&quot;: &quot;r&quot;,
          &quot;prod_hola&quot;: &quot;t&quot;
      },
      {
          &quot;rashod&quot;: 0.0,
          &quot;prihod&quot;: 0,
          &quot;prod_name&quot;: &quot;c&quot;,
          &quot;prod_hola&quot;: &quot;f&quot;
      },
      {
          &quot;rashod&quot;: 0,
          &quot;prihod&quot;: 100.0,
          &quot;prod_name&quot;: &quot;c&quot;,
          &quot;prod_hola&quot;: &quot;f&quot;
      },
      {
          &quot;rashod&quot;: 0.0,
          &quot;prihod&quot;: 0,
          &quot;prod_name&quot;: &quot;a&quot;,
          &quot;prod_hola&quot;: &quot;b&quot;
      },
      {
          &quot;rashod&quot;: 0,
          &quot;prihod&quot;: 1500.0,
          &quot;prod_name&quot;: &quot;a&quot;,
          &quot;prod_hola&quot;: &quot;b&quot;
      }]
  </code></pre>
  <h1>python</h1>
  <pre><code>dictf = reduce(lambda x, y: dict((k, v + y[k]) for k, v in x.iteritems()), values)
  print dictf
  </code></pre>
  <p>But this sum all values in dict, and output is like:</p>
  <pre><code>{'rashod': 1930.0, 'prihod': -17020.0, 'prod_name': 'abcfrtabcfrtabcfrt'}
  </code></pre>
  <p>What I want is output like this:</p>
  <pre><code>[{'rashod': 1930.0, 'prihod': -17020.0, 'prod_name': 'a','prod_hola':'b},
  {'rashod': 1930.0, 'prihod': -17020.0, 'prod_name': 'c','prod_hola':'f},
  {'rashod': 1930.0, 'prihod': -17020.0, 'prod_name': 'r','prod_hola':'t},]
  </code></pre>