我觉得你可以试试将下面的缩进,往前移一下相当于在while循环的外面if guess == secret: print "Avast! Ye got it! Found my secret, ye did !" else: print "No more gusses ! Better luck next time ,matey!" print "The secret number was",secret我在 python2.7版本运行无任何问题我估计你是其他的版本python ,解释器把你获得的输入变成 str 了,可以type(guess) 看看是什么类型你的问题出现在 if guess < secret: 你可以 把 while guess != secret and tries < 6: guess = input("what is yer guess?") #增加两句话 print type(guess) guess = int(guess) # if guess < secret: print("too low, ye scurvy dog!") elif guess > secret: print ("too high, landlubber!")