-
-
Save ysmood/7178133 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| low = 0 | |
| high = 100 | |
| guess_number = (low + high) / 2 | |
| print("Please think of a number between 0 and 100!") | |
| while True: | |
| char = raw_input("Is your secret number " + | |
| str(guess_number) + "?\n" + | |
| "Enter 'h' to indicate the guess is too high." + | |
| "Enter 'l' to indicate the guess is too low." + | |
| "Enter 'c' to indicate I guessed correctly .") | |
| if not char: | |
| break | |
| elif char == 'c': | |
| break | |
| elif char == 'h': | |
| high = guess_number | |
| elif char == 'l': | |
| low = guess_number | |
| else: | |
| print("Sorry, I did not understand your input.") | |
| guess_number = (low + high) / 2 | |
| print("Game over. Your secret number was: " + str(guess_number)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
這個語法錯誤我知道怎麼避免,但我只關心為什麼一個賦值表達式並不能像 C 那樣直接嵌入 while 判斷式裡面...
話說是什麼語言可以直接從 raw_input 看出來的吧。