+ 2
Does anyone know how it works??? need some help please
def add(x, y): return x + y def do_twice(func, x, y): return func(func(x, y), func(x, y)) a = 1 b = 2 print(do_twice(add, a, b))
4 Respostas
+ 9
Well, it feeds the do_twice() method with the add() method as both arguments and the function to perform. So you end up with add(add(1,2), add(1,2)), which performs (1+2)+(1+2)
Returns 6 obviously.
+ 5
*bows*
+ 4
No problem.
Could you pls mark my answer as best, if it helped you (of course if it really helped you)? Kind of a unique opportunity for me to grab some decent xp at this time ;)
+ 2
thnx mate