Chapters
Python114 chapters

ReferenceKeywords

global

Lets a function rebind a module-level name rather than making a local one.

Signature

global name

Returns

Nothing.

Example

Python
count = 0

def bump():
    global count
    count += 1

bump()
bump()
print(count)

Output

2

See also