我在python中編程。我試圖讓用戶猜一個數字,我相信我有正確的代碼1和100之間,但我不斷收到各地語法錯誤「而」while while循環同時生成一個隨機數的Python語法錯誤
import random
def guessthenumber():
print("Welcome user. In this game, you must correctly guess a randomly generated number between 1 and 100.")
guessamount = 1
randomnumber = random.randrange(1, 100)
numberguess = int(input("Please enter your guess")
while numberguess != numbertoguess:
if numberguess < numbertoguess:
print("You must guess higher.")
elif numberguess > numbertoguess:
print("You must guess lower.")
guessamount += 1
print("You have correctly guessed the number! It took you {} guesses".format(guessamount))
截圖:
youre在那裏你要求輸入 – 2014-11-02 12:14:55