>>> from collections import Counter >>> c = Counter() >>> c['foo'] 0 >>> c['bar'] +=1 >>> c['bar'] 1 >>>