Skip to main content
Journey Uncommon Logo
JourneyUncommon
mediumPythonmutable default trapSingle-choice MCQ

Which change is the idiomatic fix for the mutable-default-argument bug while preserving the ability for a caller to pass their own list?

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