global - To declare a global variable
Variables defined outside of a function or class are global but read-only, also known as "constants." The global keyword tells Python that the variable is read-writeable - it is not being treated as a constant.
q = 10 # A global variable def addToQ(): global q # We want to change it q = q + 5 addToQ() print(q)
Notes: Use with caution! Global variables usually should never be changed because this can cause side-effects when other code expects the global variable to behave like a constant.