Spot the bug in the mutable default

from Functions
Python 3.14 beginner 3 min 1 issue to find

Find the state leak in this tag helper.

Python
def add_tag(tag: str, tags: list[str] = []) -> list[str]:
    tags.append(tag)
    return tags

first = add_tag("urgent")
second = add_tag("gift")
print(first, second)
Open in playground
Report an error