Я новичок, борющийся с логикой / структурой моего кода.
Я пытаюсь написать виртуальный тур, который позволяет пользователю ходить из одной комнаты в другую в доме (только жесткий код).
Я начинаю в гостиной и могу go попасть в комнаты, которые связаны с гостиной, и вернуться.
Пример: go снаружи, вернитесь в гостиную.
После этого я не смогу go вернуться на улицу, пока не скопирую и не вставлю ввод для входа снаружи под входом гостиной.
Это имеет смысл? Как я могу go вернуться к определенной входной переменной без необходимости копировать и вставлять ее снова и снова и в конечном итоге получить бесконечный l oop?
PS: не для всех комнат
while True:
living_room = input("""
You are in the living room. There's a 55 inch TV, 2 sofas and a center table.
Options: Outside/ Kitchen/ Hallway
> """).lower()
if living_room == "outside":
outside = input("""
You are outside. It's a cloudy day and your house is located in a very quiet street, so, no cars are passing by.
Options: Living room/ Garage
> """).lower()
if outside == "living room":
living_room = input("""
You are in the living room. There's a 55 inch TV, 2 sofas and a center table.
Options: Outside/ Kitchen/ Hallway
> """).lower()
if outside == "garage":
garage = input("""
You are in the garage. There's a lot of junk in here, and your car is parked on the driveway.
Options: Kitchen/ Outside
> """).lower()
elif living_room == "kitchen":
kitchen = input("""
You are in the kitchen. There's a dinning table with 6 chairs, a refrigerator, stove, microwave, counter and sink.
Options: Living room/ Garage/ Backyard
> """).lower()
elif living_room == "hallway":
hallway = input("""
You are in the Hallway.
Options: Living room/ Bathroom 1/ Bedroom 1/ Bedroom 2/ Bedroom 3
> """).lower()