Sobes.tech
Intern — Senior

Analysis of scope areas in Python

livecode

Task condition

Explain how the following program works and what values will be output.

counter = 0

def outer():
    counter = 10
    def inner():
        global counter
        counter += 1
    inner()
    print(counter)

outer()
print(counter)