Question: My code isn't working. I have a couple issues, first being my rooms still don't connect, for example from the living room I can either
My code isn't working. I have a couple issues, first being my rooms still don't connect, for example from the living room I can either go north or south but it's not letting me go south into the hallway. Instead I have to east into the hallway so Im messing up somewhere there. It should work like this, you start in the living room and you can either go north or south. If you go south, you go the dining room the dining room is a dead end you can only go back up to the living room. Back to the living room this time you go north, you go into the hallway. From the hallway you have three options, east into the kitchen which is a dead end, west into the bedroom also a dead end and south back into the living room. Secondly, the start doesn't print the room desc and then after the first input, it prints it three times. Ive pasted the code below. Third, I need to create two new rooms and for some reason when I was trying to add them the code wasnt working so if anyway it would be possible for someone to add them. It would be a pantry only connected to the kitchen and a bathroom only connected to the bedroom, if not its fine I can figure it out the main problem is the rooms not connecting please try to explain and paste the new code so I can see it thanks. Ive pasted my code below.
# Creating the empty array roomlist
roomlist
# Creating rooms
room You are in a major modern living room. You see a leather couch, barely used with tiny hairs all over it You can go either north or south.", None, None
roomlist.appendroom
room You are in a petite dining room. You can only go north.", None, None, None
roomlist.appendroom
room You are in a modern hallway. There is a massive dog, that will eat you if you don't move fast. Quickly choose between the east or the west or the south.", None,
roomlist.appendroom
room You are in a brand new kitchen. You see a brand new inch cu ft Front Control Induction Range with Total Convection in Smudge Proof Stainless. You can go to the hallway in the west.", None, None
roomlist.appendroom
room Youre in the biggest master bedroom in the world. It looks like the bed is ready to be slept on There's a hallway to the east.", None, None, None,
roomlist.appendroom
# Creating a variable called current room to keep track of where they are
currentroom
# Printing room list variable
printroomlist
printroomlistcurrentroom
done False
# Started game loop
while not done:
print # Blank line
printroomlistcurrentroom # Room description printing
# Asking for input
direction inputWhere do you wanna golower # Asking for input side note # need's workss
if direction n and roomlistcurrentroom is not None:
currentroom roomlistcurrentroom
elif direction e and roomlistcurrentroom is not None:
currentroom roomlistcurrentroom
elif direction s and roomlistcurrentroom is not None:
currentroom roomlistcurrentroom
elif direction w and roomlistcurrentroom is not None:
currentroom roomlistcurrentroom
else:
printYou can't go that way!"
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
