17 мая 2024
id 7018946508Pls I don't understand how to return a function..... Can someone help me. Thanx
Please can you explain your use case
If you want to return a function you can return the name without the brackets.
def f(x):
return x * x
def return_f():
# returning f will return the function when you call return_f
return f
a = return_f()
a(2) # response is 4