Junior — Senior
Analysis of closures in Python
livecode
Task condition
What will be the output of the following example? The example illustrates the use of a closure, where the nested function accesses a variable from the outer function.
def outer():
value = 10
def inner():
return value
value = 20
return inner
closure = outer()
print(closure())
print(closure())