What You Wrote
What You Might Have Expected to Happen
A new list is created each time the function is called if a second argument isn’t provided, so that the output is:
What You Should Do Instead
Create a new object each time the function is called, by using a default arg to signal that no argument was provided (
None
is often a good choice).
No comments:
Post a Comment