Debug a function that remembers state between calls
Interview insights are lockedSee how often this is asked and which companies asked it with Buncho Pro.def add_tag(tag, tags=[]):
tags.append(tag)
return tags
print(add_tag("a"))
print(add_tag("b"))
print(add_tag("c", ["x"]))
print(add_tag("d"))
- What does this print, and why?
- Fix the function.
- Give a realistic ML example where this bug would silently corrupt results.