There are currently no frequently asked questions associated with this exercise – that’s where you come in! You can contribute to this section by offering your own questions, answers, or clarifications on this exercise. Ask or answer a question by clicking reply () below.
If you’ve had an “aha” moment about the concepts, formatting, syntax, or anything else with this exercise, consider sharing those insights! Teaching others and answering their questions is one of the best ways to learn and stay sharp.
Join the Discussion. Help a fellow learner on their journey.
Ask or answer a question about this exercise by clicking reply () below!
You can also find further discussion and get answers to your questions over in Language Help.
Agree with a comment or answer? Like () to up-vote the contribution!
Hello @retawater
This is because you call the second_nested() within the nested_function() which is not called in your script at all. Even though, is is all enclosed in outer_function() so unless you call it, the underlying code wont print anything out.
Like a domino, 3rd one wont fall unless you touch 1st (beginning of the chain)
While trying to understand the enclosing scope, found that local namespace in nested function ‘sees’ only one of 2 variables out of enclosing function.
As shown below, the first print(locals()) shows just the square_feet variable while expected to see ‘paint_coverage’: 350 in the local namespace too.
Immutable objects, such as strings or numbers, can be accessed in nested functions, but cannot be modified.
Why?
Edit: I figured out why
It’s because when you create a new variable inside the nonlocal scope or the nested function, it will make a new local variable not overwriting the existing one!