3 ms·
Yup, but the right way to do it would be a defaultdict, or a Counter anyway. from collections import defaultdict def count_names(): names = de
by avyfain 10y ago
Yup, but the right way to do it would be a defaultdict, or a Counter anyway.
from collections import defaultdict
def count_names():
names = defaultdict(int)
for name in sys.stdin.readlines():
name = name.strip()
names[name] += 1
...