Skip to main content
code•find the-bug•python
0s
+20 XP

Mutable Default Argument Trap in Python

Which line contains the subtle mutable default argument bug that persists state between function calls?

python
def append_item(item, target_list=[]):  # Line 1
    target_list.append(item)             # Line 2
    return target_list                  # Line 3
Exit to Challenges