Python Programming - Dictionaries - Discussion

Discussion Forum : Dictionaries - General Questions (Q.No. 8)
8.
How do you create a dictionary with a default value for all new keys?
dictionary.set_default(default_value)
dictionary.default_value = default_value
dictionary.default(default_value)
collections.defaultdict(default_value)
Answer: Option
Explanation:
The defaultdict from the collections module is used to create a dictionary with a default value for all new keys.
Discussion:
Be the first person to comment on this question !

Post your comments here:

Your comments will be displayed after verification.