Sobes.tech
Junior — Middle+

How does the nonlocal operator work in nested functions

livecode

Task condition

Analyze how the keyword nonlocal works in the following example, and determine whether an error will occur when attempting to call func4().


def func3():
    value = 1

    def func4():
        nonlocal value
        print(value)