def A(x, l=[]):
for i in range(x):
l.append(i*i)
print(l)
A(3)
A(2, [45, 56, 12])
A(2)
Why does this code return the following output :
[0, 1, 4]
[45, 56, 12, 0, 1]
[0, 1, 4, 0, 1]
def A(x, l=[]):
for i in range(x):
l.append(i*i)
print(l)
A(3)
A(2, [45, 56, 12])
A(2)
Why does this code return the following output :
[0, 1, 4]
[45, 56, 12, 0, 1]
[0, 1, 4, 0, 1]