I'm a total python newbie in a beginner programming class, and I'm stuck on one of our assignments. I'm supposed to be creating the bare bones start of a text game in which I move around rooms. I've managed to get the movement to work, but the "invalid command" and "exit game" commands aren't working.
rooms = {
'Foyer': {'name': 'Foyer', 'South': 'Dining Hall', 'North': 'Hallway', 'West': 'Courtyard', 'East': 'Grand Hall'},
'Dining Hall': {'name': 'Dining Hall', 'South': 'Servants Quarters', 'East': 'Kitchen', 'North': 'Foyer',
'West': 'Drawing Room'},
'Servants Quarters': {'name': 'Servants Quarters', 'North': 'Dining Hall'},
'Drawing Room': {'name': 'Drawing Room', 'East': 'Dining Hall'},
'Kitchen': {'name': 'Kitchen', 'West': 'Dining Hall'},
'Courtyard': {'name': 'Courtyard', 'East': 'Foyer'},
'Grand Hall': {'name': 'Grand Hall'},
'Hallway': {'name': 'Hallway', 'South': 'Foyer', 'East': 'Private Library'},
'Private Library': {'name': 'Private Library', 'West': 'Hallway', 'East': 'Master Bedroom'},
'Master Bedroom': {'name': 'Master Bedroom', 'West': 'Private Library'}
}
directions = ['North', 'South', 'East', 'West']
player_room = rooms['Foyer']
# turn below into definition that can be called on later
while True:
print()
print('You have entered the {}.'.format(player_room['name']))
command = input('\nEnter a direction: North, South, East, or West')
if command in directions:
if command in player_room:
player_room = rooms[player_room[command]]
else:
print("You face a wall. There is no doorway here.")
elif command == "Exit" or "exit":
print("Play again soon.")
break
else:
print("Type a cardinal direction to move. Directions are case-sensitive.")
This is my code so far. Whenever I test inputting an invalid command, like a number or a random word, it just gives me the 'exit' text and ends the program. I thought the problem was the order of the commands, so I swapped them around and messed with the statements a little, but then it would just repeatedly give me the error text even if I typed "exit". How do I stop one from always taking priority over the other?