How to write a applytwice function that apply twice for another function with two arguments? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 2

How to write a applytwice function that apply twice for another function with two arguments?

For example, the second function I want is def xpowery(x, y): return x**y

23rd Jun 2019, 9:01 AM
Junjie
Junjie - avatar
3 Answers
+ 7
ok, here is a base sample: def apply_twice(func, arg, arg1): return func(func(arg, arg1),arg1) def mult(x,y): return x * y print(apply_twice(mult, 4, 7))
24th Jun 2019, 6:18 PM
Lothar
Lothar - avatar
+ 5
See sololearn python course with functional programming: https://www.sololearn.com/learn/Python/2459/
23rd Jun 2019, 9:07 AM
Lothar
Lothar - avatar
+ 2
This was the lesson that I got stuck with this problem. The add_five function only has one argument and works with apply_twice which has one function and one argument ( func, argu). I need help on how to write apply_twice for a function with two arguments.
24th Jun 2019, 11:21 AM
Junjie
Junjie - avatar