3
我正在Python中猜測玩家選擇的數字。TypeError:最多輸入1個參數,得到3
# Computer Guessing Game
# The computer tries to guess your number
print("Think of a number, and I will try to guess it. If my guess is right,")
print("say 'yes'.If my guess is too high, say 'lower'. And if my guess is")
print("too low, say 'higher'.\n")
answer = input("Is it 50? ")
guess = 50
while answer != "yes":
hilo = input("Is it higher or lower? ")
if hilo == "lower":
guess %= 50
answer = input("Is it", guess, "?")
if hilo == "higher":
guess %= 150
answer = input("Is it", guess, "?")
print("I win!")
input("Press the enter key to exit.")
但是,在運行時,線15和代碼的18
answer = input("Is it", guess, "?")
回報「類型錯誤:輸入預計最多1個參數,得到3」我不知道如何解決這個問題,所以任何幫助將不勝感激。
謝謝Martijn。我會嘗試。 – Francois 2013-02-13 15:30:48