Why is it that when I run this code, the error is
'name position is not defined??'
I think I have already defined position
before call it
the code is for using r,l,i,d
to change the position(x,y)
def get_position_in_direction(position, direction):
position=(0,1)
x,y=position
direction=input("Please enter an action (enter '?' for help): ")
if direction=='r':
xi,yi=(1,0)
elif direcrion=='l':
xi,yi=(-1,0)
elif direction=='u':
xi,yi=(0,1)
elif direction=='d':
xi,yi=(0,-1)
else:
pass
position=position+xi,yi
return position
print(get_position_in_direction(position, direction))