I am trying to write code in Python for a text based game for my class and am having several issues. First, for some reason, the code isn't even running now when I try to debug it. When it was working, every time I'd enter a command, it would always print multiple lines of 'Enter a valid move', whether or not the command was valid. I am also having trouble on how to collect the item from each room and add it to the inventory.
rooms = {
'Living Room': {'north': "Parent's Room", 'east': "Kitchen",'south': 'Dining Room', 'west' : 'Office'},
"Parent's Room": {'east': "Amir's Room", 'south' : 'Living Room', 'item' : 'cape'},
"Amir's Room": {'west': "Parent's Room"},
'Office': {'east': 'Living Room', 'item' : 'Toy Phone'},
'Dining Room': {'north': 'Living Room', 'east': 'Garage', 'item': 'Toy Taco'},
'Garage' : {'west': 'Dining Room', 'item': 'Toy Car'},
'Kitchen' : {'west': 'Living Room', 'north' : 'Pantry', 'item' : 'Toy Fork'},
'Pantry' : {'south' : 'Kitchen', 'item' : 'Chocolate'}
}
direction = '' # Creates empty variable for direction.
location = 'Living Room' # Places user in default starting point
inventory = []
def show_status():
''' Shows player status and commands.'''
def main():
# Keep game going until player enters 'exit'
while True:
print('----------------------------')
print('You are in the {}.'.format(location))
input = input('Enter a direction to move: ').strip().lower() # Take input from user to move them in desired direction.
direction = input.split()
# Check to see if user entered valid move.
for command in rooms[location]:
if direction == command:
location = rooms[location][direction]
print(direction)
elif direction != command:
print('Enter a valid move')