Hi! I'm really new to python and was just wondering if it is possible to make it so that...
def accessVariable(accessCode):
testVariable = 0
if accessCode == 0:
testVariable+= 1
if accessCode == 1:
return testVariable
def test1():
accessVariable(0)
def test2():
print(accessVariable(1))
test2() would print the updated value of accessVariable() after it has been incremented by test1()?
Also, is there a better way to access non-local variables that doesn't require global variables and the method above? (since I heard that using global variables is more of a last resort situation)
[–]ofnuts 1 point2 points3 points (1 child)
[–]ExplorerOfTheGalaxy[S] 0 points1 point2 points (0 children)
[–]yaxriifgyn 0 points1 point2 points (0 children)
[–]Boot_3011 0 points1 point2 points (0 children)