Enable Javascript in your browser and then refresh this page, for a much enhanced experience.
Second solution in Creative category for Sum by Type by kdim
from typing import Tuple # s == ('', 'size', '', 'in', '', '')
def sum_by_types(items: list) -> Tuple[str, int]: # n == (0, 0, 12, 0, 45, 0)
s, n = list(zip(*[['', 0]] + [[i, 0] if isinstance(i, str) else ['', i] for i in items]))
return ("".join(s), sum(n))
Jan. 27, 2021
Comments: