Question #624

A variable can be global and nonlocal at the same time.

A variable cannot be global and nonlocal at the same time. If a variable is nonlocal , it implies that it is global too.


def my_main_function():
    def my_nested_function():
        global my_variable
        nonlocal my_variable

will throw a SyntaxError exception. (programiz.com/python-programming/global-local-nonlocal-va...)


Comment on Disqus:

Comment on Twitter:

Question difficulty: 🔵🔵🔵🔵🔵


Similar questions: