【发布时间】:2014-08-29 06:22:53
【问题描述】:
如何包含一个 while 循环来让用户一直猜测,直到他们在以下 Jython 程序中得到正确答案?
import random
def numberGuess():
printNow("I'm thinking of a number between 1 and 10")
guess = 0
randNum = random.randrange(1,11)
guess = int(input("Try to guess the number: "))
if guess > 10:
print("Wrong! You guessed too high")
elif guess < 1:
print("Wrong! You guessed too low")
else :
print(" you got it")
【问题讨论】:
标签: jython jython-2.5