Skip to main content
๐Ÿ”ฎ Output PredictionPY Python Hard+35 XP

Mutable Default Argument

What happens when we call this twice?

Python
def add_item(item, lst=[]):
    lst.append(item)
    return lst

print(add_item("a"))
print(add_item("b"))

๐Ÿ”ฎ What is the output?

Priygop - Leading Professional Development Platform | Expert Courses & Interview Prep