human
I am working on the file "Closure.ipynb".
The first task is:
We can see that the nested function printer() was able to access the non-local variable msg of the enclosing function.
In the example above, what would happen if the last line of the function print_msg() returned the printer() function instead of calling it? This means the function was defined as follows:
Can you write Python code for it?
assistant
#Here would happen if the last line of the function print_msg() returned the printer() function instead of calling it.

def print_msg(msg):     # This is the outer enclosing function
    def printer():      # This is the nested function
        print(msg)
    return printer      # This is changed from the above example

another = print_msg("Hello")
another()