我知道不能使用Goto,也知道Goto不是答案。我已经阅读了类似的问题,但我就是找不到解决我的问题的方法。
所以,我正在编写一个程序,其中你必须猜一个数字。这是我遇到问题的部分的摘录:
你会怎么做?
所以,我正在编写一个程序,其中你必须猜一个数字。这是我遇到问题的部分的摘录:
x = random.randint(0,100)
#I want to put a label here
y = int(raw_input("Guess the number between 1 and 100: "))
if isinstance( y, int ):
while y != x:
if y > x:
y = int(raw_input("Wrong! Try a LOWER number: "))
else:
y = int(raw_input("Wrong! Try a HIGHER number "))
else:
print "Try using a integer number"
#And Here I want to put a kind of "goto label"`
你会怎么做?
int(raw_input(
改为input(
。至于标签,你的代码剩下的部分是什么?你想调用一个函数吗? - cwahlsgoto
(1,2,3)。我也不明白为什么它从来都不是答案。 - Anton Shepelev