What does the collections.defaultdict class do?
- A Sorts keys automatically
- B Creates a default value for a missing key instead of raising KeyError
- C Prevents duplicate values
- D Limits dictionary size
Answer
Creates a default value for a missing key instead of raising KeyError
defaultdict(list) is a common idiom for grouping items without checking whether the key already exists.





