This question already has answers here:
Python - Repeating code with a while loop
(3个答案)
2年前关闭。
我正在为业余爱好制作游戏,这是一种基于冒险文字的游戏。我无法弄清楚id是如何实现的,因此,如果他们键入除“ Get up”以外的任何内容,该过程将重复,并且代码会反复询问他们,直到获得正确答案为止。
(3个答案)
2年前关闭。
我正在为业余爱好制作游戏,这是一种基于冒险文字的游戏。我无法弄清楚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")
最佳答案
也许使用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")
关于python - 无法弄清楚如何在Python3中重复处理,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/51869330/
10-10 18:48