This question already has an answer here:
-
*
/questions/370357/python-variable-scope-error
/questions/370357/python-variable-scope-error
10 answers
Answers
You can fix this by passing parameters rather than relying on Globals
def function(Var1, Var2): if Var2 == 0 and Var1 > 0: print("Result One") elif Var2 == 1 and Var1 > 0: print("Result Two") elif Var1 < 1: print("Result Three") return Var1 - 1 function(1, 1)
Source
License : cc by-sa 3.0
http://stackoverflow.com/questions/10851906/python-3-unboundlocalerror-local-variable-referenced-before-assignment