def initColors():
BLACK = (0,0,0)
RED = (255,0,0)
BLUE = (0,0,255)
LIGHTGRAY = (128,128,128)
DARKGRAY = (64,64,64)
WHITE = (255,255,255)
initColors()
def initOtherVars():
nhover = WHITE
hover = RED
mselected = BLACK
selected = RED
initOtherVars()
I want it to set the value of nhover to the value of WHITE, but I get this error:
Traceback (most recent call last):
File "C:\Users\jarr3\Desktop\Python\Battlr\battlrSelectionScreen1.py", line 30, in <module>
initOtherVars()
File "C:\Users\jarr3\Desktop\Python\Battlr\battlrSelectionScreen1.py", line 27, in initOtherVars
nhover = WHITE
NameError: name 'WHITE' is not defined
It seems that a variable cannot be assigned to the value of a variable that is defined in a function in a function, even if the first function is called before the second one is even defined. Why is this? And is there a different way to accomplish what I'm trying to do. (Besides just not using functions, I would like to keep using functions.) Thanks.