I'm not able to understand the mechanism behind this behavior in python.
def fun(s=[]):
s.append(1)
print s
fun()
fun()
Output is:
[1]
[1,1]
Why does python "remember" the value of the list passed on the function?
I'm not able to understand the mechanism behind this behavior in python.
def fun(s=[]):
s.append(1)
print s
fun()
fun()
Output is:
[1]
[1,1]
Why does python "remember" the value of the list passed on the function?