Name

Globals

Examples
# We create the global x by declaring it outside of a function. 
x = 0

def keyPressed():
    # We want to modify the global x. 
    global x 
    x = x + 1

def draw():
    # We wish to read the global x.
    ellipse(x, height / 2, 10, 10)
Description Global variables are declared outside functions and are readable throughout the program. If you wish to modify or create a global variable from within a function, you must use the global Python statement.
Syntax
	x = 0

	def foo():
	    global x
	    x = 5 

Updated on Mon Sep 21 15:53:25 2020.

If you see any errors or have comments, please let us know.