Challenge 3: Updating Outer Scope Values Again
Time for another coding challenge.
Problem statement
This problem is a variation of the previous problem statement. This time, implement a nested function update_var()
that takes in value
as a parameter, and updates the value of the var
variable in the outer function scope to the one supplied as a parameter. It shouldn’t affect the value of the var
variable in the global scope.
Sample input
var = 9
def some_function(num):
var = 5
update_var(num)
return var
print(some_function(6))
print(var)
Sample Outptut
6
9
Get hands-on with 1400+ tech skills courses.