You can do one of 2 things: either use a global variable (which should be mostly avoided), or use return values. The global method:
x=0
.
.
def directions():
.
.
def north():
global x
x=x+1
print("moved north...")
or, the return value:
def directions():
current_location = 0
.
.
if move == "North":
current_location = North(current_location)
.
.
def North(location):
print("moved north...")
return location+1
Judging by your question and the existence of y
, you can do the following:
def directions():
.
.
if move == "North":
(x,y) = North(x,y)
.
.
def North(x,y):
return (x+1,y)
def East(x,y):
return (x,y+1)
def South(x,y):
return (x-1,y)