Thursday, 23 November 2017

TIL

from collections import defaultdict
a = defaultdict(int)

a[whatever] += 1 # without ever initializing for any whatever key

No comments:

Post a Comment