Question 8
Back to Exercise
What does d.setdefault("k", []) do?
- A Always resets d["k"] to []
- B Returns [] without changing d
- C Returns d["k"] if it exists; otherwise sets d["k"] = [] and returns that list Correct
- D Deletes "k"
Correct Answer: Option C
That is why d.setdefault(k, []).append(x) groups values in one line.
Discussion & Comments 0
Share your method, a shortcut, or ask about a step you didn't follow.
No comments yet. Be the first to share your solution!