Now I’ve gotten a slight grasp on dictionaries ,the join() and split I am working on understanding nested list and how to process them at least I think that that is my problem at this point here is the code I’m playing around with It’s supposed to print location and a list of directions then ask for input as to which direction do you want to go but I get stuck with it repeating the same location never changing.
I got it going once by correcting an error in exits but when I typed it out again I get the same
Error.
I got it going once by correcting an error in exits but when I typed it out again I get the same
Error.
location={
0:'you are at home',
1:'you are on a road' ,
2:'you are on a hillside',
3:'you are looking at a lake',
4:'you are in the country' ,
5:'you are in outer space! ' }
exits=[
{'q':0},
{'w':2,'e':3,'n':5,'s':4,'q':0},
{'n':5,'e':1,'q':0},
{'w':1,'q':0},
{'n':1,'w':2,'q':0},
{'w':2,'s':1}]
loc=1
while True:
avail_exits=','.join(exits[loc].keys())
print(location[loc])
if loc == 0:
break
direction=input('what direction do you want to go in?' + avail_exits)
if direction in exits[loc]:
loc == exits[loc][direction]
else:
print('you cannot go in that direction')
