Не могу понять, как повторить процессы в Python3 [duplicate]

1

Im делает игру для хобби, своего рода приключенческой текстовой игры. Я не могу понять, как id делает это так, если они печатают что-то другое, кроме "Get up", процесс повторяется, и код повторно запрашивает их повторно, пока они не получат правильный ответ.

getup = input("What is your action?: ")
if getup == "Get Up":
    print("You stand up and get your bearings. You scan the enviroment. There is a small passage way to the north, and tight crevis to the east. Everywhere else is just cave wall")
elif getup == "get up":
    print("You stand up and get your bearings. You scan the enviroment. There is a small passage way to the north, and tight crevis to the east. Everywhere else is just cave wall")
elif getup == "Get up":
    print("You stand up and get your bearings. You scan the enviroment. There is a small passage way to the north, and tight crevis to the east. Everywhere else is just cave wall")
elif getup == "GET UP":
    print("You stand up and get your bearings. You scan the enviroment. There is a small passage way to the north, and tight crevis to the east. Everywhere else is just cave wall")
else:
    print("Celsia: You do not have time to waste,",name,"!!. You must Get Up")
Теги:
python-3.x
repeat

1 ответ

2
Лучший ответ

Может быть, используя во while цикла:

getup = input("What is your action?: ")
while getup.lower()!='get up':
    print("Celsia: You do not have time to waste,",name,"!!. You must Get Up")
    getup = input("What is your action?: ")
print("You stand up and get your bearings. You scan the enviroment. There is a small passage way to the north, and tight crevis to the east. Everywhere else is just cave wall")
  • 1
    Отлично спасибо.

Ещё вопросы

Сообщество Overcoder
Наверх
Меню