Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

list as a function parameter. How it works?

def fun(x, a=[]): a.append(x) print (a)

fun(3) fun(5) fun([7,8]) fun({7,8})

o/p: [3] [3, 5] [3, 5, [7, 8]] [3, 5, [7, 8], {8, 7}]

list as a function parameter. How it works?

def fun(x, a=[]): a.append(x) print (a)

fun(3)
fun(5)
fun([7,8])
fun({7,8})fun({7,8})

o/p:

o/p: [3] [3, 5] [3, 5, [7, 8]] [3, 5, [7, 8], {8, 7}]

list as a function parameter. How it works?

def fun(x, a=[]): a.append(x) print (a)

fun(3)
fun(5)
fun([7,8])
fun({7,8})

o/p:

[3] [3, 5] [3, 5, [7, 8]] [3, 5, [7, 8], {8, 7}]

list as a function parameter. How it works?

def fun(x, a=[]): a.append(x) print (a)

fun(3)
fun(5)
fun([7,8])
fun({7,8})

o/p:

[3] [3, 5] [3, 5, [7, 8]] [3, 5, [7, 8], {8, 7}]

list as a function parameter. How it works?

def fun(x, a=[]): a=[]):

    a.append(x)
     print (a)

(a)
fun(3)
fun(5)
fun([7,8])
fun({7,8})

o/p:

[3] [3, 5] [3, 5, [7, 8]] [3, 5, [7, 8], {8, 7}]

list as a function parameter. How it works?

def fun(x, a=[]):

    a.append(x)
    print (a)

fun(3)
fun(5)
fun([7,8])
fun({7,8})

o/p:

[3] [3, 5] [3, 5, [7, 8]] [3, 5, [7, 8], {8, 7}]

list as a function parameter. How it works?

def fun(x, a=[]):

a= []):
     a.append(x)
     print (a)
(a)

fun(3)
fun(5)
fun([7,8])
fun({7,8})

o/p:

[3] [3, 5] [3, 5, [7, 8]] [3, 5, [7, 8], {8, 7}]

list as a function parameter. How it works?

def fun(x, a= []):
a.append(x) print (a)

fun(3)
fun(5)
fun([7,8])
fun({7,8})

o/p:

[3] [3, 5] [3, 5, [7, 8]] [3, 5, [7, 8], {8, 7}]

list as a function parameter. How it works?I can't able to understand how the outputs work.

def fun(x, a= []):
b= []): a.append(x) ... b.append(x) print (a) ... print(x,' ',b) ... fun(7) 7 [7] fun([9, 7]) [9, 7] [7, [9, 7]] fun([9, 8]) [9, 8] [7, [9, 7], [9, 8]]

fun(3)
fun(5)
fun([7,8])
fun({7,8})

o/p:

[3] [3, 5] [3, 5, [7, 8]] [3, 5, [7, 8], {8, 7}]

list as a function parameter. I can't able to understand how the outputs work.

def fun(x, b= []): ... b.append(x) ... print(x,' ',b) ... fun(7) 7 [7] fun([9, 7]) [9, 7] [7, [9, 7]] fun([9, 8]) [9, 8] [7, [9, 7], [9, 8]]

list as a function parameter. I can't able to understand how the outputs work.

def fun(x, b= []): ... b.append(x) ... print(x,' ',b) ... fun(7) 7 [7] fun([9, 7]) [9, 7] [7, [9, 7]] fun([9, 8]) [9, 8] [7, [9, 7], [9, 8]]

list as a function parameter. I can't able to understand how the outputs work.

def fun(x, b= []): ... b.append(x) ... print(x,' ',b) ... fun(7) 7 [7] fun([9, 7]) [9, 7] [7, [9, 7]] fun([9, 8]) [9, 8] [7, [9, 7], [9, 8]]

list as a function parameter. I can't able to understand how the outputs work.parameter.

def fun(x, b= []): ... b.append(x) ... print(x,' ',b) ... fun(7) 7 [7] fun([9, 7]) [9, 7] [7, [9, 7]] fun([9, 8]) [9, 8] [7, [9, 7], [9, 8]]

list as a function parameter.

![>>> def fun(x, b= []): ... b.append(x) ... print(x,' ',b) ...

def fun(x, b= []): ... b.append(x) ... print(x,' ',b) ... fun(7) 7 [7] fun([9, 7]) [9, 7] [7, [9, 7]] fun([9, 8]) [9, 8] [7, [9, 7], [9, 8]]8]] ](http://)

list as a function parameter.

![>>> def fun(x, b= []): ... b.append(x) ... print(x,' ',b) ...

def fun(x, b= []): ... b.append(x) ... print(x,' ',b) ... fun(7) 7 [7] fun([9, 7]) [9, 7] [7, [9, 7]] fun([9, 8]) [9, 8] [7, [9, 7], [9, 8]] ](http://)8]]

list as a function parameter.

def fun(x, b= []): ... b.append(x) ... print(x,' ',b) ... fun(7) 7 [7] fun([9, 7]) [9, 7] [7, [9, 7]] fun([9, 8]) [9, 8] [7, [9, 7], [9, 8]]

list as a function parameter.

.

>>> def fun(x, b= []):
 ...   b.append(x)
 ...   print(x,'   ',b)
 ...
 >>> fun(7)
 7     [7]
 >>> fun([9, 7])
 [9, 7]     [7, [9, 7]]
 >>> fun([9, 8])
 [9, 8]     [7, [9, 7], [9, 8]]

8]] >>>