I am getting the error "local variable 'Xold' referenced before assignment". I don't understand why I am getting the error as I have assigned the variable in question before I attempt use it.
def calculator (newX,newY):
    global count
    if  count==0:
        Xold = newX
        Yold = newY
        count+=1
        print(Xold,Yold) #prints 97.9 which is correct. 
    else:
        Xdistance = newX - Xold
        Ydistance = newY - Yold
        print(Xdistance,Ydistance)
        parser()
Just to mention, count is set to 0 at the beginning of the code.
 
    