I have a function in python and I want to declare 2 variables only the first time I call this function and then change their values, something like this :
def function():
  x=0
  z=2
  if(x>z):
    other_function()
  else:
    x+=1
With this way,every time I call the function(), x becomes 0 and z becomes 2. 
I tried to make them global outside of the function() but it gives me error :
UnboundLocalError: local variable 'x' referenced before assignment
How can I declare the values the first time I call the function()?
 
     
     
     
     
     
     
     
    