Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR PYTHON

how to make a variable global in python


x = 5 #Any variable outside a function is already a global variable

def GLOBAL():
	global y #if a variable is inside a function, use the 'global' keyword to make it a global variable
    y = 10 # now this variable (y) is global
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #variable #global #python
ADD COMMENT
Topic
Name
5+1 =