Accessing and altering a variable across classes


#1

I am currently on Ex 45, making my own game. I am trying to build in a guess system, where if you guess incorrectly 10 times across the whole game, you lose. How do I get a class to access this variable, alter it and hand it off to the next class?


#2

You probably want to use the global keyword:

THE_STATE = 0

def somefunc():
    global THE_STATE
    THE_STATE = 1000

That will change the variable.