How does collections.defaultdict work?

I’ve read the examples in python docs, but still can’t figure out what this method means. Can somebody help? Here are two examples from the python docs >>> from collections import defaultdict >>> s=”mississippi” >>> d = defaultdict(int) >>> for k in s: … d[k] += 1 … >>> d.items() [(‘i’, 4), (‘p’, 2), (‘s’, … Read more