title: Sum multiple values for same key in lists using python
body: <p>I have a list which looks like this:</p>
  
  <pre><code>(151258350, 2464)
  (151258350, 56)
  (151262958, 56)
  (151258350, 56)
  (151262958, 112)
  (151262958, 112)
  (151259627, 56)
  (151262958, 112)
  (151262958, 56)
  </code></pre>
  
  <p>And I want a result that looks like this:</p>
  
  <pre><code>151259627 56
  151262958 448
  151258350 2576
  </code></pre>
  
  <p>And here's my code: </p>
  
  <pre><code>for key, vals in d.items():
      tempList.append((key, reduce(add, vals))) 
  </code></pre>
  
  <p>here, d is the list with the key-value pair. tempList is the List in which the values will be appended after summing them by key. and add is a fuction:</p>
  
  <pre><code>def add(x, y): return x+y
  </code></pre>
  
  <p>If this question has already been asked, please point me there as I was unsuccessful in finding it myself.</p>