The quiz where the difficulty automagically adapts to the player's Python knowledge
This is a question page. You can use this page to bookmark a question. Start a new quiz!
The keyword nonlocal indicates that a variable inside a nested function does not belong to the scope of that inner function but to the function encapsulating it. ``` def myfunc1(): x = "John" def myfunc2(): x = "hello" myfunc2() return x print(myfunc1()) ``` will output: ``` >>>John ``` The keyword global is different. It indicates that the scope of a variable is defined at the module level. (w3schools.com/python/ref_keyword_nonlocal.asp)
Which keyword prevents changing variables in a nested function?— The Python Quiz (@thepythonquiz) March 1, 2021
👇 Comment the answer, like and retweet! #python
Question difficulty: 🔵🔵🔵🔵🔵