how to set a global variable in a python function code example Example: global variable python a = 0 def testFor(): global a if(a == 0): #run code