How to sum list of tuples?
<p>I have a list of tuples:</p>

<pre><code>[ (a,1), (a,2), (b,1), (b,3) ]
</code></pre>

<p>I want to get the sum of both the <code>a</code> and <code>b</code> values. The results should be in this format:</p>

<pre><code>[ { 'key' : a, 'value' : 3 }, {'key' : b, 'value' : 4 } ]
</code></pre>

<p>How can I do this?</p>

<pre><code>from collections import Counter

a = [('a', 1), ('a', 2), ('b', 1), ('b', 3)]
c = Counter()
for tup in a:
    c = c + Counter(dict([tup]))
</code></pre>

python