0
Functions in python
can anyone explain please, why the result is 9 and how does func(x)(x) an func1(x)(x) works? def func(x): return lambda y: (x + y + 1) def func1(x): return lambda y : (func(x)(x)+y+1) print(func1(3)(1))
3 RĂ©ponses
+ 5
I explained here Zohrab Mammadov
https://code.sololearn.com/cSLLppSeuIos/?ref=app
+ 2
func1(3)(1)
Here func1(3) returns a lambda, where x is 3, and y is 1. We pass 1 to the parameter of the lambda returned by func1(3).
-> lambda y: func(3)(3)+1+1
func(3)(3) works as same as func1(3)(1). Here first (3) is for the func. The second (3) is for the lambda returned by func(3).
func(3)(3) -> 3+3+1
So func(3)(3)+1+1 = 3+3+1+1+1 = 9
0
thanks a lot for your help SAYEDđ§đ©đ”đž and CarrieForle