> masteringswe_
conceptual

nonlocal - reassign enclosing variable

What does this code output?

pythondef func():
    message = "Hello"
    
    def inner():
        nonlocal message
        message = "Hello, Python!"
        print(message)
    
    print(message)
    inner()
    print(message)

func()