The default list assigned to b is created when the f functions is defined. After that, each call to f() (that does not get a "b" parameter) uses this common list.

examples/advanced/mutable_default_parameter.py
def f(a, b = []):
    b.append(a)
    return b

print(f(1))
print(f(2))
print(f(3))

examples/advanced/mutable_default_parameter.out
[1]
[1, 2]
[1, 2, 3]

Use None instead: