Sobes.tech
Junior — Senior

Function behavior with a mutable default parameter

livecode

Task condition

Determine what output will be for the following code fragment:


def f(total, arr=[]):
    arr.append(total)
    print(arr)

lst = [1]
f(10)
f(10)
f(10, lst)
f(10)
f(10)