A past puzzle — fully playable. 4 attempts, hints on wrong guesses.
stdle-124.py
1defgrow(item,bag=[]):
2bag.append(item)
3returnlen(bag)
4print(grow('a'),grow('b'),grow('c'))
Mutability
Answer & explanation
Console output
1 2 3
Why
The default argument bag=[] is evaluated a single time when the function is defined, producing one list reused by every call. Each call appends to that same list, so its length climbs across calls. The fix is bag=None plus bag = [] inside the body.