Question: My code isn't working when I attempt to move from room to room. This is in python. def commandsHandle(item): print(Directions you can move in are
My code isn't working when I attempt to move from room to room. This is in python.
def commandsHandle(item): print("Directions you can move in are North, South, East, West") print("Item available to you in this room, if you choose to accept it: ", item)
while True: asked = input("Please enter: GET
def displayStatus(room, whatYouHave, currentItem): print("You are in the: ", room) print("You already have with you: ", whatYouHave) print("You now have available to you: ", currentItem) print()
# Pseudocode or Flowchart for Code to Get an Item def main(): places = { 'LivingRoom': {'South': 'StorageRoom', 'North': 'Library', 'East': 'Kitchen', 'West': 'BedroomOne'}, 'StorageRoom': {'North': 'LivingRoom', 'East': 'Basement'}, 'Basement': {'West': 'StorageRoom'}, 'BedroomTwo': {'South': 'Kitchen'}, 'BedroomOne': {'East': 'LivingRoom'}, 'Kitchen': {'North': 'BedroomTwo', 'West': 'LivingRoom'}, 'Library': {'East': 'Office', 'South': 'LivingRoom'}, 'Office': {'West': 'Library'} }
arms = { 'LivingRoom': 'n/a', 'Kitchen': 'RottenMeat', 'StorageRoom': 'Medkit', 'Library': 'BookofUndetection', 'Office': 'baseballbat', 'BedroomOne': 'friendone', 'BedroomTwo': 'friendtwo', 'Basement': 'monster' }
where = 'LivingRoom' what = []
while True: displayStatus(where, what, arms[where]) ans = commandsHandle(arms[where]) if ans == arms[where]: what.append(ans) continue else: if ans in places[where]: where = places[where][ans] if where == 'Basement': print("You are now battling the monster...") if len(what) > 3: print("-------------------------------------------") print("You narrowly escaped the mansion with your life") else: print("-------------------------------------------") print("You died :-(") break
else: print() print("No way to go") continue
main()
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
