本文介绍了在python3中循环时如何转到下一行?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我做了一个小的游戏,您可以猜出这个数字.但是我有一个问题.我需要能够重新开始循环,而不是重复错误/正确答案"的文字.
这是我所拥有的:
I have made a little "game where you guess the number. However I have a problem. I need to be able to restart the loop instead of having the "wrong/right answer" text be repeated.
Here is what I have:
number = 34
guess = int(input("guess the number"))
while guess != 34:
if guess > number:
print("Too high")
else:
print("too low")
if guess == number:
print("You got it.")
推荐答案
这篇关于在python3中循环时如何转到下一行?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!