当我键入' no'无论如何它仍然重复,我该如何解决?
试图询问用户是否玩,但当我输入“否”时,它会重复,无论
import random
play = True
while play:
secret = random.randint(1,101)
while True:
guess = int(input("Input your guess: "))
if guess == secret:
print ("Correct!")
again = str(input("Do you want to play? (Type Yes or No): "))
break
elif guess < secret:
print ("Too Low")
continue
elif guess > secret:
print ("Too High")
continue
if again == "no" or "No":
play = False
我希望能够输入“是”并再次玩猜谜游戏,当我输入“否”时,它会停止
trying to ask user to play or not but when I type no it repeats anyway regardless
import random
play = True
while play:
secret = random.randint(1,101)
while True:
guess = int(input("Input your guess: "))
if guess == secret:
print ("Correct!")
again = str(input("Do you want to play? (Type Yes or No): "))
break
elif guess < secret:
print ("Too Low")
continue
elif guess > secret:
print ("Too High")
continue
if again == "no" or "No":
play = False
I want to be able to type 'yes' and plays the guessing game again and when I type 'no' it stops
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论