Returning a value from a function to a global variable
Solution 1:
You must call global
within the function to let the function know to use the global variable.
For example:
def gen_random_secret():
global secret
secret = ""
for i in range(4):
n = random.randrange(6)
secret += colors[n]
return secret
Instead of:
global secret
def gen_random_secret():
secret = ""
for i in range(4):
n = random.randrange(6)
secret += colors[n]
return secret