when i am trying to find the output of the below program. I got little confused , I am not able to understand the output.
def func(x,l =[]):
for i in range(x):
l.append(i*i)
print(l)
func(2)
func(3,[3,2,1])
func(3)
Output :-
first call output :- [0,1]
second call output :- [3,2,1,0,1,4]
third call output :- [0,1,0,1,4]
when i called third function call it doesn't create empty list ( we provided as default argument ). Instead it created like this [0,1].
I know that each function call doesn't interfere with other call. Any one explain this one
I tried to figure it out what happening in the background. But i am not able to figure it out.