What is the output?
def append_to(element, lst=[]):
lst.append(element)
return lst
print(append_to(1))
print(append_to(2))
print(append_to(3)) Answer
[1]
[1, 2]
[1, 2, 3] Default mutable arguments are shared across calls. The list is created once when the function is defined, not each time it's called.
💡 Memory Trick: "Mutable defaults are born once, live forever — use None as default instead"