def add(s, o): s = map(int, s) s = { 1: (c for c in s if c % 2), 2: (c for c in s if c % 2 == 0), }.get(o, s); return sum(s)
- def add(s, o):
return {0: sum(int(c) for c in s),1: sum(int(c) for c in s if int(c)%2),2: sum(int(c) for c in s if not(int(c)%2))}.get(o, 0);- s = map(int, s)
- s = {
- 1: (c for c in s if c % 2),
- 2: (c for c in s if c % 2 == 0),
- }.get(o, s);
- return sum(s)