Enable Javascript in your browser and then refresh this page, for a much enhanced experience.
First solution in Clear category for Convert and Aggregate by ssk8
from collections import defaultdict as dd
def conv_aggr(data: list[tuple[str, int]]) -> dict[str, int]:
data_dict = dd(int)
for k, v in data:
data_dict[k] += v
if not data_dict[k] or not k: del(data_dict[k])
return data_dict
Sept. 10, 2022
Comments: