title: Python: Elegantly merge dictionaries with sum() of values
body: <p>I'm trying to merge logs from several servers. Each log is a list of tuples (<code>date</code>, <code>count</code>). <code>date</code> may appear more than once, and I want the resulting dictionary to hold the sum of all counts from all servers.</p>
  
  <p>Here's my attempt, with some data for example:</p>
  
  <pre class="lang-python prettyprint-override"><code>from collections import defaultdict
  
  a=[("13.5",100)]
  b=[("14.5",100), ("15.5", 100)]
  c=[("15.5",100), ("16.5", 100)]
  input=[a,b,c]
  
  output=defaultdict(int)
  for d in input:
          for item in d:
             output[item[0]]+=item[1]
  print dict(output)
  </code></pre>
  
  <p>Which gives:</p>
  
  <pre><code>{'14.5': 100, '16.5': 100, '13.5': 100, '15.5': 200}
  </code></pre>
  
  <p>As expected.</p>
  
  <p><strong>I'm about to go bananas because of a colleague who saw the code. She insists that there must be a more Pythonic and elegant way to do it, without these nested for loops. Any ideas?</strong></p>