Enable Javascript in your browser and then refresh this page, for a much enhanced experience.
6-liner: defaultdict does the job solution in Clear category for Aggregate and Count by Stensen
from collections import defaultdict
def aggregate_and_count(items: list) -> dict:
d = defaultdict(int)
for key, val in items:
d[key] += val
return d
Sept. 14, 2021