0

Where does the return value go?

def creat_func(n): return lambda x: x % n x = 11 a = creat_func(2) print(a) That is wrong but why? I hope to find someone who can illustrate that case

11th Sep 2020, 4:21 PM
Taher Mohamed Ismail
Taher Mohamed Ismail - avatar
4 ответов
+ 3
its called high order function, the creat_func function are returning another function/lamda. you need to execute the return value again accroding to the lambda defined in creat_func to see the result. try this print(a(9));
11th Sep 2020, 4:33 PM
Rei
Rei - avatar
0
Sorry but if i print what you mention for it gives me error it doesn't make sense to me
11th Sep 2020, 4:43 PM
Taher Mohamed Ismail
Taher Mohamed Ismail - avatar
0
Thank you so much now i got it
11th Sep 2020, 4:45 PM
Taher Mohamed Ismail
Taher Mohamed Ismail - avatar