Exercise

Checking for closure

You're teaching your niece how to program in Python, and she is working on returning nested functions. She thinks she has written the code correctly, but she is worried that the returned function won't have the necessary information when called. Show her that all of the nonlocal variables she needs are in the new function's closure.

Instructions 1/3

undefined XP
    1
    2
    3
  • Use an attribute of the my_func() function to show that it has a closure that is not None.