Functions can read global variables:
greeting = "Hello"
def greet(name):
print(greeting + ", " + name) # Can read greeting
greet("Alice") # Hello, Alice
But if you try to modify a global variable inside a function, Python creates a local variable instead:
count = 0
def increment():
count = count + 1 # Error! Can't read count before assigning
To modify a global, you need the global keyword.