by pwf · 12y ago · 0 comments
In [1]: from collections import defaultdict
In [2]: d = defaultdict(lambda: 1)
In [3]: d['foo'] += 1
In [4]: d['foo']
Out[4]: 2That is to say, a word that appears once should get a count of 2, and word that doesn't appear at all should get a count of 1.
I should learn to read...