As I'm new to python I've started the topic of default arguments As per that of the definition I've understood that the default arguments are evaluated only once and that at the point of function definition but this code fragment created the confusion
def f(a, L=None):
if L is None:
L = []
L.append(a)
return L
In the above code L being a variable Modified to list on the first function call ex.f(1) But even for the second time when the function is called L is being modified to list ex.. f(1) f(2) Results in [1] [2] Could you'll actually be precise in explaining how the above code evaluation is done