0

Can anybody explain this function to me?

Can anyone explain to me this coding function? def apply_twice(func, arg): return func(func(arg)) def add_five(x): return x + 5 print(apply_twice(add_five, 10)) Output is 20 Thank you in advance!!

9th Jan 2022, 8:35 PM
Boubaker Benaissa
Boubaker Benaissa - avatar
2 Respostas
+ 2
1.) add_five does 10 + 5 -> 15 2.) apply_twice repeats 1.): 15 + 5 -> 20
9th Jan 2022, 9:00 PM
Lisa
Lisa - avatar
0
apply_twice(add_five,10)) = add_five(add_five(10)) = add_five(15) = 20
9th Jan 2022, 10:00 PM
YoPycode