Question: use the created dictionary to correct the code. rooms = { 'Great Hall': { ' South ' : 'Bedroom', 'North': 'living Room', 'East': 'Kitchen', 'West':

use the created dictionary to correct the code. rooms ={ 'Great Hall': {'South': 'Bedroom', 'North': 'living Room', 'East': 'Kitchen', 'West': 'Library'}, 'Bedroom': {'North': 'Great Hall', 'East': 'Cellar', 'item': 'Red Stone'}, 'Cellar': {'West': 'Bedroom', 'item': 'Blue Stone'}, 'Kitchen': {'West': 'Great Hall', 'North': 'Dining room', 'item': 'Green Stone'}, 'Library': {'East': 'Great Hall', 'item': 'Yellow Stone'}, 'Living Room': {'South': 'Great Hall', 'East': 'Basement', 'item': 'Purple Stone'}, 'Basement': {'West': 'Living Room', 'item': 'Orange Stone'}, 'Dining Room': {'South': 'Kitchen', 'item': 'Godzilla'} # Villain room } def show_status(current_room, inventory): print(f"You are in the {current_room}.") print(f"Inventory: {inventory}") if 'item' in rooms[current_room]: print(f"You see a {rooms[current_room]['item']}") print("--------------------") def main(): current_room = 'Great Hall' inventory =[] stones_needed =6 while True: show_status(current_room, inventory) # Check for win condition (player has all 6 stones) if len(inventory)== stones_needed and current_room == 'Dining Room': print("Congratulations! You have collected all items and defeated Godzilla!") break # Check for loss condition (player enters Dining Room without all stones) if current_room == 'Dining Room' and len(inventory)< stones_needed: print("NOM NOM...GAME OVER! Godzilla has defeated you!") break # Get player input command = input("Enter your move (go [North/South/East/West] or get [item]): ").strip().lower() # Handle movement if command.startswith("go "): direction = command.split()[1].capitalize() if direction in rooms[current_room]: current_room = rooms[current_room][direction] else: print("You can't go that way!") # Handle item collection elif command.startswith("get "): item = command.split()[1].capitalize()+" Stone" if 'item' in rooms[current_room] and rooms[current_room]['item']== item: inventory.append(item) print(f"You have picked up the {item}.") del rooms[current_room]['item'] # Remove item from the room after it's collected else: print("There is no such item here!") # Invalid command else: print("Invalid command!") if __name__=="__main__": main()

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!