Use Counter
>>> from collections import Counter
>>> c=Counter()
>>> for d in l:
... c.update(d)
...
>>> dict(c)
{'a': 30, 'b': 15}
1
solved python : Get the sum of values of a key in list of dictionaries [duplicate]
Use Counter
>>> from collections import Counter
>>> c=Counter()
>>> for d in l:
... c.update(d)
...
>>> dict(c)
{'a': 30, 'b': 15}
1
solved python : Get the sum of values of a key in list of dictionaries [duplicate]