'Python Moving between rooms with a Dictions
I'm working on a coding project for class, which requires the user to be able to move between rooms. I'm having an issue with one specific part of the code. I can't figure out how to pull the room name from the dictionary. I can get the rest to work. The line I need help with is "('You are in the {}.'.format(player_room[]))". Here is my code:
rooms = {
'Great Hall': {'South': 'Bedroom'},
'Bedroom': {'North': 'Great Hall', 'East': 'Cellar'},
'Cellar': {'West': 'Bedroom'}
}
while player_move != 'Exit':
if player_move in moves:
if player_move in player_room:
player_room = rooms[player_room[player_move]]
print('You are in the {}.'.format(player_room[]))
print('Enter a move:')
player_move = input()
elif player_move not in player_room:
print('Invalid move.')
print('Enter a move:')
player_move = input()
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
