Mutable Default Leaks Predictions
Interview insights are lockedSee how often this is asked and which companies asked it with Buncho Pro.A prediction service stores results with this function. Users report that results from earlier requests appear in later responses.
def add_result(result, results=[]):
results.append(result)
return results
print(add_result(1)) # [1]
print(add_result(2)) # [1, 2]
Why does this happen and how do you fix it?