import random
print ("welcome to my game")
guessestaken = 0
number = random.randint(1,10)
print ("what is your name")
myname = raw_input()
print ("Well,"+ myname + "," + "I'm thinking of a number between 1 and 10"
while guessesTaken < 6:
print ("take a guess")
guess = raw_input()
guess = int(guess)
guesstaken = guesstaken + 1
if guess < number :
print ("your guess is low")
if guess > number :
print ("your guess is high")
if guess == number :
break
if guess == number :
print ("You are awesome ")
guesstaken = str(guessestaken)
print ("You guessed the number in " + guessestaken + " try")
if guess != number:
print "You lost"
每次我試圖執行它的錯誤「而guessesTaken < 6: ^ 語法錯誤:無效的語法」的while
語句之前出現什麼是錯,此代碼猜測遊戲蟒蛇
你錯過拼寫gusestaken(首都)後「1至10」 – AdamKG
缺少一個右括號 – elyashiv
這個問題似乎是題外話,因爲它是由一個錯字造成的問題。 – madth3