Enable Javascript in your browser and then refresh this page, for a much enhanced experience.
Using dict with types as keys solution in Clear category for Sum by Type by erykcoapl
from typing import Tuple
def sum_by_types(items: list) -> Tuple[str, int]:
sums_by_type = {}
for v in ['', 0] + items:
t = type(v)
sums_by_type[t] = sums_by_type.get(t, t()) + v
return tuple(sums_by_type.values())
March 14, 2021