在书的帮助下,我正在 python 上猜测你的数字游戏(计算机猜测人类认为使用更高/更低输入的数字)。我昨天开始学习python,今天整天都在寻求帮助,但只是感到困惑。这是代码(到目前为止)和错误。
import random
print("Welcome to the Pick a Number Game! Pick a number between 1 and 10 and I \n will guess it!")
number = random.randint (1, 10)
print("Are you thinking of", number,"?")
guess = input("Am I right on, higher, or lower? ")
if guess == "higher":
number2 = random.randint (number, 10)
input("Are you thinking of", number2,"?")
elif guess == "lower":
number3 = random.randint (1, number)
input("Are you thinking of", number3,"?")
elif guess == "right on":
print("I won! Thanks for playing!")
input("Press the enter key to exit.")
错误:
Traceback (most recent call last):
File "C:\Users\Adam\Desktop\Number Challenge.py", line 8, in <module>
input("Are you thinking of", number2,"?")
TypeError: input expected at most 1 arguments, got 3
我迷路了,我不明白类似问题的答案。我将不胜感激代码的解决方案以及您可以提供的解释。谢谢您的帮助!