Python quiz · 32 questions

Mutable default argument

Read the code

What does this print?


def add(item, items=[]):
    items.append(item)
    return items

add(1)
print(add(2))

When is the default list created?

  • 1–3 answer
  • ← previous
Question 20 of 3259%