How to create single Python dict from a list of dicts by summing values with common keys?
<p>I have a list of dictionaries, e.g:</p>

<pre><code>dictList = [
    {'a':3, 'b':9, 'c':4},
    {'a':9, 'b':24, 'c':99},
    {'a':10, 'b':23, 'c':88}
]
</code></pre>

<p>All the dictionaries have the same keys e.g. <em>a</em>, <em>b</em>, <em>c</em>. I wish to create a single dictionary with the same keys where the values are the sums of the values with the same keys from all the dictionaries in the original list.</p>

<p>So for the above example, the output should be:</p>

<pre><code>{'a':22, 'b':56, 'c':191}
</code></pre>

<p>What would be the most efficient way of doing this? I currently have:</p>

<pre><code>result = {}
for myDict in dictList:
    for k in myDict:
        result[k] = result.setdefault(k, 0) + myDict[k]
</code></pre>
