Skip to main content

← Python

Mutable default

easy

def add(x, items=[]): items.append(x); return items add(1); print(add(2)) prints?

Your answer

Answers

Stuck?

Open hints one at a time. The write-up explains a full solution.

Discussion

Ask a question or share a tip. Please don’t post full solutions. Posts appear once a moderator approves them.

No posts yet.