В настоящее время я пишу текстовую игру, чтобы немного попрактиковаться в операторах if/elif, и у меня возникла проблема с выходом из операторов if/elif. Я хочу, чтобы он продолжился с исходного оператора if/elif, начиная с того места, где находится начальный оператор elif (последние две строки кода). Возможно ли это? Вот что у меня есть на данный момент:
cave_or_jungle = input("Do you go into the JUNGLE or the CAVE?").lower()
if cave_or_jungle == "cave":
print("You go into the cave! The cave is cold and dark. You find a rusty lantern and hear strange growling deeper inside.")
deeper_or_leave = input("Do you go DEEPER or LEAVE?").lower()
if deeper_or_leave == "deeper":
print("Deep in the cave, a giant beast jumps out of the darkness.")
fight_or_run = input("Do you FIGHT or RUN?").lower()
if fight_or_run == "fight":
print("The beast is too powerful. You are defeated.")
print("GAME OVER")
# Game ends
elif fight_or_run == "run":
print("You run back outside and follow the jungle path.")
# Exit statement here to continue onto line 47 below. Code now runs up to this statement and then stops.
elif deeper_or_leave == "leave":
print("You go back outside.")
# Exit statement here to continue onto line 47 below. Code now runs up to this statement and then stops.
elif cave_or_jungle == "jungle":
print("You are in the jungle!")
print("The jungle is thick and noisy. You hear water nearby and see smoke rising through the trees.")
input("Do you follow the RIVER or the SMOKE?")
# Have previous two elif statements run to this elif statement and progress with story.
Выход из операторов if/elif в Python ⇐ Python
Программы на Python
1778953502
Anonymous
В настоящее время я пишу текстовую игру, чтобы немного попрактиковаться в операторах if/elif, и у меня возникла проблема с выходом из операторов if/elif. Я хочу, чтобы он продолжился с исходного оператора if/elif, начиная с того места, где находится начальный оператор elif (последние две строки кода). Возможно ли это? Вот что у меня есть на данный момент:
cave_or_jungle = input("Do you go into the JUNGLE or the CAVE?").lower()
if cave_or_jungle == "cave":
print("You go into the cave! The cave is cold and dark. You find a rusty lantern and hear strange growling deeper inside.")
deeper_or_leave = input("Do you go DEEPER or LEAVE?").lower()
if deeper_or_leave == "deeper":
print("Deep in the cave, a giant beast jumps out of the darkness.")
fight_or_run = input("Do you FIGHT or RUN?").lower()
if fight_or_run == "fight":
print("The beast is too powerful. You are defeated.")
print("GAME OVER")
# Game ends
elif fight_or_run == "run":
print("You run back outside and follow the jungle path.")
# Exit statement here to continue onto line 47 below. Code now runs up to this statement and then stops.
elif deeper_or_leave == "leave":
print("You go back outside.")
# Exit statement here to continue onto line 47 below. Code now runs up to this statement and then stops.
elif cave_or_jungle == "jungle":
print("You are in the jungle!")
print("The jungle is thick and noisy. You hear water nearby and see smoke rising through the trees.")
input("Do you follow the RIVER or the SMOKE?")
# Have previous two elif statements run to this elif statement and progress with story.
Ответить
1 сообщение
• Страница 1 из 1
Перейти
- Кемерово-IT
- ↳ Javascript
- ↳ C#
- ↳ JAVA
- ↳ Elasticsearch aggregation
- ↳ Python
- ↳ Php
- ↳ Android
- ↳ Html
- ↳ Jquery
- ↳ C++
- ↳ IOS
- ↳ CSS
- ↳ Excel
- ↳ Linux
- ↳ Apache
- ↳ MySql
- Детский мир
- Для души
- ↳ Музыкальные инструменты даром
- ↳ Печатная продукция даром
- Внешняя красота и здоровье
- ↳ Одежда и обувь для взрослых даром
- ↳ Товары для здоровья
- ↳ Физкультура и спорт
- Техника - даром!
- ↳ Автомобилистам
- ↳ Компьютерная техника
- ↳ Плиты: газовые и электрические
- ↳ Холодильники
- ↳ Стиральные машины
- ↳ Телевизоры
- ↳ Телефоны, смартфоны, плашеты
- ↳ Швейные машинки
- ↳ Прочая электроника и техника
- ↳ Фототехника
- Ремонт и интерьер
- ↳ Стройматериалы, инструмент
- ↳ Мебель и предметы интерьера даром
- ↳ Cантехника
- Другие темы
- ↳ Разное даром
- ↳ Давай меняться!
- ↳ Отдам\возьму за копеечку
- ↳ Работа и подработка в Кемерове
- ↳ Давай с тобой поговорим...
Мобильная версия