Hi
I am new to python and come from C language background. I couldn't able to
understand this
>>> def f(a, L=[]):
... L.append(a)
... return L
...
>>> print(f(1))
[1]
>>> print(f(2))
[1, 2]
>>> print(f(3))
[1, 2, 3]
>>> def f(a, L=10):
... L=10+a
... return L
...
>
On 07/08/16 04:22, rishabh mittal wrote:
> I am new to python and come from C language background. I couldn't able to
> understand this
>
> >>> def f(a, L=[]):
> ... L.append(a)
> ... return L
> ...
>
print(f(1))
> [1]
>
print(f(2))
> [1, 2]
def f(a, L=10):
> ... L=
On 07Aug2016 09:19, Alan Gauld wrote:
On 07/08/16 04:22, rishabh mittal wrote:
I am new to python and come from C language background. I couldn't able to
understand this
>>> def f(a, L=[]):
... L.append(a)
... return L
print(f(1))
[1]
print(f(2))
[1, 2]
[...]
In the first example