Language Syntax

Global — Python syntax

Declare that assignments to listed names refer to the module namespace, not a function-local binding. The declaration is a compile-time directive for the current code block.

Formal Syntax & Structure

python syntaxpython
global name [, name ...]

Working Example

Example Snippetpython
count=1def bump():    global count    count+=1bump()print(count)
Python Reference