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.
def f(a, b = ): b.append(a) return b print(f(1)) print(f(2)) print(f(3))
 [1, 2] [1, 2, 3]
Use None instead: