To modify a global variable inside a function, declare it with global:
count = 0
def increment():
global count
count = count + 1
increment()
print(count) # 1
increment()
print(count) # 2
The global count line tells Python "I mean the global count, not a new local one."
Use global sparingly. Functions that modify global state are harder to understand and test.