Python | Functions | Question 10

Last Updated :
Discuss
Comments

What will be the output of the following code?

Python
def outer():
    x = 10
    def inner():
        nonlocal x
        x += 5
        return x
    return inner

closure = outer()
print(closure())
print(closure())


15
20


15
15


10
15


5
5


Share your thoughts in the comments