Шаг 1 из 3+110 XP
collections: Counter, defaultdict
Коллекции «из коробки» делают код короче.
collections
from collections import Counter, defaultdict
Counter("banana") # {'a':3, 'n':2, 'b':1}
d = defaultdict(int)
for c in "abc": d[c] += 1Коллекции «из коробки» делают код короче.
from collections import Counter, defaultdict
Counter("banana") # {'a':3, 'n':2, 'b':1}
d = defaultdict(int)
for c in "abc": d[c] += 1