func used as a function was not defined. Why? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

func used as a function was not defined. Why?

def add(x, y): return x + y def do_twice(func, x, y): return func(func(x, y), func(x, y)) a = 5 b = 10 print(do_twice(add, a, b))

26th Apr 2017, 7:04 AM
Benson John
Benson John - avatar
2 Answers
+ 4
in the code playground the result is 30 without an error. there's no point to define func, it can be any function
26th Apr 2017, 7:15 AM
rdhelli
rdhelli - avatar
0
thought as much
26th Apr 2017, 7:16 AM
Benson John
Benson John - avatar