Enable Javascript in your browser and then refresh this page, for a much enhanced experience.
Dict | Short solution in Clear category for Convert and Aggregate by Wartem
def conv_aggr(data: list[tuple[str, int]]) -> dict[str, int]:
comb = {}
for pair in data:
if(pair[0]):
comb[pair[0]] = comb.get(pair[0], 0) + pair[1]
return {k:v for k,v in comb.items() if v!=0}
Sept. 10, 2022