【发布时间】:2014-06-02 01:47:59
【问题描述】:
我正在为我班上的一项作业编写这个简单的游戏。我正在努力做到这一点,一旦用户输入“是”,它就会停止询问他们是否愿意前往关东地区。但如果他们输入“否”,它会将他们循环回到开头,告诉他们他们首先要前往关东地区。
编辑:我将如何做到这一点,如果用户输入是,它会停止循环,如果他输入否,它会继续循环?
while gender=='boy' or gender=='Boy':
#REGION KANTO
print("We will first proceed to the Kanto Region.")
print("You are currently facing the Kanto Region Pokemon Master, John!")
#ATTACK
attack=input("Would you like to use cut and hurt his Pokemon?")
if attack=='yes' or attack=='Yes':
print(starterP,"used cut! Foe Pokemon has fainted!")
print("You will advance to the next region!")
print("=====================================================")
if attack=='no' or attack=='No':
print(starterP,"got attacked!",starterP,"has fainted!")
print("Game over!")
print("=====================================================")
【问题讨论】:
-
break会破坏它,但您的真正问题是什么? -
使用
break声明 -
你无法摆脱无限循环
标签: python loops while-loop