Refer to the exhibit. What is the output?
Correct; default list persists across calls.
Why this answer
The function uses a mutable default argument `lst=[]`. On the first call, `append_to_list(1)` uses the default list and appends 1, returning `[1]`. On the second call, `append_to_list(2, [])` passes an explicit empty list, so it appends 2 to that new list, returning `[2]`.
On the third call, `append_to_list(3)` uses the default list again, which now contains `[1]` from the first call, so appending 3 yields `[1, 3]`. Thus the output is `[1] [2] [1,3]` printed on separate lines.
Exam trap
The PCEP exam often tests the mutable default argument trap, where candidates mistakenly believe each function call creates a fresh default list, rather than understanding that the default object is created once and reused, leading to cumulative modifications across calls.
How to eliminate wrong answers
Option A is wrong because it assumes each call creates a new list, ignoring Python's mutable default argument behavior where the same list object is reused across calls without an argument. Option B is wrong because Python does not raise an error for mutable default arguments; it is a common pitfall but syntactically and semantically valid. Option C is wrong because it incorrectly suggests the second call returns `[2]` instead of `[1, 2]`, misunderstanding that the default list persists and accumulates values from previous calls.