+ 2
Question about functions
Can someone help in describing below functions how the output will be 18?! All results count as (3+6+9) = 18 ? OR!?? def f(x=[]): x+=[3] return sum(x) print(f()+f()+f()) The output is: 18
3 Respuestas
+ 7
First call x becomes [3]. Second call x becomes [3, 3]. Third call x becomes [3, 3, 3]. Therefore, f returns 3, 6, and 9, which added together is your printed 18.
+ 2
Thanks John
+ 2
Right