import random
while True:
number1 = random.randint(1,3)
guess = float( input( "Guess the number:" ))
if number1 == guess:
print("Correct")
break
else:
print("Wrong, try again")
if guess < number1:
print ("Your number is too low")
if guess > number1:
print ("Your number is too high")
print ("The answer is", number1)
答案 0 :(得分:0)
尝试一下:
import random
number1 = random.randint(1,3)
guess = 0
while number1 != guess:
guess = float( input( "Guess the number:" ))
if guess < number1:
print ("Wrong! Your number is too low")
if guess > number1:
print ("Wrong! Your number is too high")
print ("Correct! The answer is", number1)