Login to manage your account

Please enter a valid email address.
Forgot Password?
Please enter a valid password.
OR

Don't have an account yet? Sign up

What does the collections.defaultdict class do?

  1. A Sorts keys automatically
  2. B Creates a default value for a missing key instead of raising KeyError
  3. C Prevents duplicate values
  4. 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.

All Python MCQs

Login to manage your account

Please enter a valid email address.
Forgot Password?
Please enter a valid password.
OR

Don't have an account yet? Sign up as