This is because globals don't bleed into the scope of your function. You have to use the global
statement to force this for assignment:
>>> COUNT = 0
>>> def increment():
... global COUNT
... COUNT += 1
...
>>> increment()
>>> print(COUNT)
1
Note that using globals is a really bad idea - it makes code hard to read, and hard to use. Instead, return a value from your function and use that to do something. If you need to have data accessible from a range of functions, consider making a class.
It's also worth noting that CAPITALS
is generaly reserved for constants, so it's a bad idea to name your variables like this. For normal variables, lowercase_with_underscores
is preferred.