3 ms·
Here is a one-liner standard library version: from itertools import groupby keyfunc = lambda x: x['thing'] [{'thing': name, 'count': sum(t['count'] for
by psyklic 5y ago
Here is a one-liner standard library version:
from itertools import groupby
keyfunc = lambda x: x['thing']
[{'thing': name, 'count': sum(t['count'] for t in things)}
for name,things in groupby(sorted(mylist, key=keyfunc), keyfunc)]
- oli5679 5y agoThanks this is great