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 showstatuscurrentroom, inventory: printfYou are in the currentroom printfInventory: inventory if 'item' in roomscurrentroom: printfYou see a roomscurrentroomitem print def main: currentroom 'Great Hall' inventory stonesneeded while True: showstatuscurrentroom, inventory # Check for win condition player has all stones if leninventory stonesneeded and currentroom 'Dining Room': printCongratulations You have collected all items and defeated Godzilla!" break # Check for loss condition player enters Dining Room without all stones if currentroom 'Dining Room' and leninventory stonesneeded: printNOM NOM...GAME OVER! Godzilla has defeated you!" break # Get player input command inputEnter your move go NorthSouthEastWest or get item: striplower # Handle movement if command.startswithgo : direction command.splitcapitalize if direction in roomscurrentroom: currentroom roomscurrentroomdirection else: printYou can't go that way!" # Handle item collection elif command.startswithget : item command.splitcapitalize Stone" if 'item' in roomscurrentroom and roomscurrentroomitem item: inventory.appenditem printfYou have picked up the item del roomscurrentroomitem # Remove item from the room after it's collected else: printThere is no such item here!" # Invalid command else: printInvalid command!" if namemain: main
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
