What is the correct fix?
def add(item, bucket=[]):
bucket.append(item)
return bucket
- Default to None, build inside
- Default to a tuple instead
- Copy
bucketbefore append - Return a new list each call
A mutable default is created once and shared across every call.
Play Problem Solving ▸