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 is wrong with def add(item, bucket=[]) as a function signature?

  1. A Nothing, it is idiomatic
  2. B The default list is created once at definition time and shared across all calls
  3. C Lists cannot be default arguments
  4. D It causes a syntax error
Answer

The default list is created once at definition time and shared across all calls

The mutable default persists between calls, accumulating values unexpectedly. Use None as the default and create the list inside the function.

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