Daily #1 · 29 September 2026
The list that remembers Medium
What does this print?
def add(item, bucket=[]):
bucket.append(item)
return bucket
add("a")
print(add("b"))
Show the answer
A: ['a', 'b']
Why: A default value is made once, when the function is defined, not each time it is called. Both calls append to the same list. The fix is bucket=None, then bucket = [] if bucket is None else bucket inside the function.