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 tokareva.anastasiya.tch
from collections import defaultdict
def conv_aggr(data: list[tuple[str, int]]) -> dict[str, int]:
d = defaultdict(int)
for t in data:
d[t[0]] += t[-1]
if d[t[0]] == 0 or t[0] == "":
del d[t[0]]
return dict(d)
Sept. 17, 2022
Comments: