Variable definition error

I’m using a python script as a controller to move an object and i need to define a variable v and later increment its value based on keystrokes signals from a keyboard sensor.
I defined it in the usual way “v=0”, but the problem is that it never gets increased, its value is always 0.
How can i fix this?

how do you expect anyone to know why your code isn’t doing what you expect, if you don’t show us the code in question?