def apply_twice(func, arg): return func(func(arg)) def add_five(x): return x + 5 print(apply_twice(add_five, 10)) Can someone please explain how the above example returned an answer of 20?
4/23/2018 5:44:25 AM
Troy Kelley3 Answers
New Answerapply_twice(add_five, 10) does the same as add_five(add_five(10)) So it adds 5 to 10 twice, which results in 20.
Sololearn Inc.
535 Mission Street, Suite 1591Send us a message