继续收到此语法错误
TypeError:输入最多需要1个参数,得到3
有谁知道如何解决这个问题?
from random import randint
from tkinter import *
po = ["Rock", "Paper", "Scissors"]
player = False
cpu = po[randint(0, 2)]
while player == False:
player = input("Rock", "Paper", "Scissors?")
if player == computer:
print("Tie")
elif player == "Rock":
if computer == "Paper":
print("You lose!", computer, "covers", player)
else:
print("You win!", player, "smashes", computer)
elif player == "Paper":
if computer == "Scissors":
print("You lose!", computer, "cuts", player)
else:
print("You win!", player, "covers", computer)
elif player == "Scissors":
if computer == "Rock":
print("You lose!", computer, "smashes", player)
else:
print("You win!", player, "cut", computer)
else:
print("That's not a valid play. Check your spelling!")
player = False
computer = po[randint(0,2)]
答案 0 :(得分:1)
你在滥用player = input("Rock, Paper, Scissors?")
。传递给它的参数仅仅是提示的提示,因此只能是一个字符串。
<iframe width="560" height="315" src="https://www.youtube.com/embed/J3HKaQlzS8Y" frameborder="0" gesture="media" allowfullscreen></iframe>
可能更像你想要的。
答案 1 :(得分:1)
似乎你从来没有真正让这个人有机会输入更多的岩石,纸张或剪刀,你应该按照
的方式做一些事情。player = str(input("Rock, Paper, or Scissors?"))
这样玩家可以分配给玩家选择的任何一个