Feb-23-2022, 09:55 PM
(This post was last modified: Feb-23-2022, 09:56 PM by deanhystad.)
The global keyword tells Python to look for the following symbols in the global scope instead of the local scope. Placing "global check" at the top of the file does not do anything at all because you are currently in the global scope.
global only makes sense inside a function. Here the "global check" tells Python that the "check" inside this function is the global variable "check".
global only makes sense inside a function. Here the "global check" tells Python that the "check" inside this function is the global variable "check".
def sample_fcn() global check # The global has to be inside the function check += 1