Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Hello I am doing an assignment for my IT class. It is the moving between rooms part of my project. I have to output what

Hello I am doing an assignment for my IT class. It is the moving between rooms part of my project. I have to output what room they are in and take in input commands such as go North, go South, go East, go West, or exit. I have not added the instructions or basic outputs yet as I am just trying to get the moving to work. Here is what I have. Please help. I have been stuck on this section for a few hours and nothing I have watched has explained it well enough for me to understand.

 # Here is a dictionary for each room and each direction rooms = { 'Great Hall': { 'South': 'Bedroom' }, 'Bedroom': { 'North': 'Great Hall', 'East': 'Cellar' }, 'Cellar': { 'West': 'Bedroom' } } #user start in the Great hall and named as a variable (current_room) current_room = 'Great Hall' #I am trying to be able to hash my dictionary and get the values to be able to move to new room based on direction direction = rooms[current_room].keys() new_room = rooms[current_room].values() #while statement for getting input and moving between the rooms while True: print('You are in the', current_room) next_move = input('Enter a command:').split() if next_move[0] == 'exit': # the way to exit the game print('Thank you for playing the Dragon Text Adventure Game!') break for direction in rooms[current_room]: #trying to get new room current_room = new_room print(current_room)

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Secrets Of Analytical Leaders Insights From Information Insiders

Authors: Wayne Eckerson

1st Edition

1935504347, 9781935504344

More Books

Students also viewed these Databases questions