Home »
Python »
Python Programs
Python program to return function from another function
Here, we will write a Python program with a function that returns another function.
By Shivang Yadav Last updated : January 05, 2024
Python allows programmers to return a function from another function like it allows function as an argument.
This is possible because python treats its functions as class objects.
Program to return a function from another function
# function - foo()
def foo():
print("I am Foo")
# function - koo() returning foo
def koo():
return foo
# calling the koo()
x=koo()
# calling function returned by koo()
x()
Output
The output of the above example is:
I am Foo
To understand the above program, you should have the basic knowledge of the following Python topics:
Python Basic Programs »