Roma A
0
Q:

nested functions in python

def print_msg(msg):
    # This is the outer enclosing function

    def printer():
        # This is the nested function
        print(msg)

    return printer  # returns the nested function


# Now let's try calling this function.
# Output: Hello
another = print_msg("Hello")
another()
1
# Python program to illustrate  
# nested functions  
def outerFunction(text):  
    text = text  
    
    def innerFunction():  
        print(text)  
    
    innerFunction()  
    
if __name__ == '__main__':  
    outerFunction('Hey !')  
0

New to Communities?

Join the community