+ 1
Error in the program given in course
This program in the course is giving error: def function(variable): variable += 1 print(variable) function(7) print(variable)
2 odpowiedzi
+ 2
you didn't save the value 7 in any variable so ofc when the scope of the function ends, you can't use the variable which you used in that function.
+ 1
Okay now. Try it like this.
def function(variable):
variable += 1
print(variable)
variable = 7
function(variable)
print(variable)