无法弄清楚如何在Python3中重复处理

时间:2018-08-16 03:48:14

标签: python python-3.x repeat

我正在为一款爱好游戏而设计,这是一种基于冒险文字的游戏。我无法弄清楚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")

1 个答案:

答案 0 :(得分: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")