Why does calling several times in a row the following function:
a = []
def test(a,b):
if b > 0:
a.append(1)
return a
with test(a,4), it enlarges the list a each time, but calling several times in a row the function:
a = 0
def test(a,b):
if b > 0:
a += 1
return a
with test(a,4) returns 1 every single time instead of 1, 2, 3, etc.?
It looks like lists get updated by a function and retain their updated value even after the function finished to execute, while this behavior doesn't hold for integers (and I guess floats and several other types).