You want to use the global keyword inside your functions in order to allow your variable to be modified outside the defining scope.

Actually you think you want globals,but usually they lead to grief, since it can be hard to debug -- for instance when you forget to declare global inside a function, you can read variables defined in external scope but not modify it. So it is easy to get confused.

Consider using a class, then you can store things like that as class instance variables. Then it is never ambiguous which copy of the variable you are modifying.