The Shared Default Bucket
def add_item(item, bucket=[]):
bucket.append(item)
return bucket
first = add_item("a")
second = add_item("b")
print(first)
print(second)
print(first is second)
bucket is never passed in by either call, so it falls back to the default. What do the three print calls output?
Sign in to answer questions and track your progress
Sign In