A global variable cannot be accessed within a function since it has local scope inside the variable. But if you try to print a variable defined outside a function inside the function, it works.
v = 5
def func():
print(v)
func()
This is perfectly valid code
v = 5
def func():
v += 1
print(v)
func()
Now this errors out. Why?