Home / Report Question

Q. What does `dict.setdefault('key', default)` do?
  • A. Sets a new key only if it exists
  • B. Returns the value if key exists; otherwise sets it to default
  • C. Raises an error if key doesn’t exist
  • D. Deletes the key