Instance variables are members of Python classes. To create an instance variable for a Python class, declare the variable inside the class's __init__ method.
From reading your question, it sounds like you want to use global variables, not instance variables. To create a global variable declare it outside a method. To modify a global variable inside a method, declare the variable as global in the method.
x = 0
def do_something()
global x
x += 1
Using global variables should be avoided in most cases, especially for larger programs. For larger programs using classes and instance variables is better than using global variables, but you can get away with using global variables for small programs.