+ 5

[SOLVED] Please explain the outputs (I know the difference between a=a+b and a+=b in lists) :-

def f(a,l=[]): l+=[a] return l print(f(2),f(3)) #Output: [2, 3] [2, 3] def f(a,l=[]): l=l+[a] return l print(f(2),f(3)) #Output: [2] [3]

2nd Oct 2020, 10:54 AM
abhinav
abhinav - avatar
2 Respuestas
+ 8
Here is my comment on this question. it is too much text to post it direct. https://code.sololearn.com/cIUOZJn559r3/?ref=app
2nd Oct 2020, 2:07 PM
Lothar
Lothar - avatar
2nd Oct 2020, 11:40 AM
Avinesh
Avinesh - avatar