import random
print"hello what is your name?"
name = raw_input()
print"hello", name
print"wanna play a game? y, n"
choice = raw_input()
if choice =='y':
print'good lets start a number guessing game'
elif choice =='n':
print'maybe next time'
exit()
random.randint(1,10)
number = random.randint(1,10)
print'pick a number between 1-10'
numberofguesses = 0
guess = input()
while numberofguesses < 10:
if guess < number:
print"too low"
elif guess > number:
print"too high"
elif guess == number:
print'your correct the number is', number
break
if guess == number:
print'CONGRATS YOU WIN THE GAME'
當我進入我的猜測到程序中只給了我例如 一個輸出我進入8 程序輸出是「過高」 但當我再次猜測輸出是空白時,我該如何解決這個問題? 你好你叫什麼名字?如何讓我的程序移動到下一個ELIF在python
ed
hello ed
wanna play a game? y, n
y
good lets start a number guessing game
pick a number between 1-10
2
too low
>>> 5
5
>>> 3
3
>>> 2
2
>>>
顯示您的輸入和輸出。你對你的問題的描述是不可思議的。 http://sscce.org/ – Marcin 2012-08-02 18:31:25
@EdwardLaPiere:那些'>>>'你看到的意思是你已經不在你的程序中了。這些數字正在由口譯員進行評估,只是被吐了回來。 (你的程序因爲你的'break'在錯誤的地方而終止,如下面的評論所述)。 – gsk 2012-08-02 18:35:42
這是更好嗎? – 2012-08-02 18:36:49