Skip to content

Glossary: Python Beyond the Basics

defaultdict

Also written: collections.defaultdict

A dict that creates a starting value automatically the first time you use a missing key. `defaultdict(list)` makes grouping easy, such as grouping products by customer.

Where the book teaches it

Related terms

Counter