this function are different , can someone help me understand this difference?
def f1(x, y=[]):
y.append(x)
return sum(y)
def f2(x, y=None):
if y is None:
y = []
y.append(x)
return sum(y)
for example:
the output of this print(f1(10)and then print(f1(30)) gives : 10 then 30
the output of this print(f2(10)and then print(f2(30)) gives : 10 then 40