我正在尝试用 Python 制作一个石头、纸、剪刀的游戏,我想我几乎拥有它,但我的代码并没有给我任何回报。我希望也许这里有人可以帮助我。我的代码一开始不会有任何问题,它会从用户那里获得输入,但是一旦用户将某些内容放入其中,它只会在幕后进行所有比较,并且不会返回声明。任何人都可以帮忙吗?(这也是我的计算机科学课的作业,所以我的老师很老套,希望我们用 Python、Ruby、Java 来运行它)
def pythonRubyJava():
Python=1
Ruby=2
Java=3
mylist3=[1,2,3]
cpu=random.choice(mylist3)
player1=input("Python, Ruby, or Java? ")
if (cpu == Python) and (player1 == Python):
print("The computer chose Python and you chose Python")
print("You tied.")
elif (cpu == Python) and (player1 == Ruby):
print("The computer chose Python and you chose Ruby")
print("You lost.")
elif (cpu == Python) and (player1 == Java):
print("The computer chose Python and you chose Java")
print("You won!")
elif (cpu == Ruby) and (player1 == Ruby):
print("The computer chose Ruby and you chose Ruby")
print("You tied.")
elif (cpu == Ruby) and (player1 == Python):
print("The computer chose Ruby and you chose Python")
print("You won!")
elif (cpu == Ruby) and (player1 == Java):
print("The computer chose Ruby and you chose Java")
print("you lost.")
elif (cpu == Java) and (player1 == Java):
print("The computer chose Java and you chose Java")
print("You tied.")
elif (cpu == Java) and (player1 == Python):
print("The computer chose Java and you chose Python")
print("You lost.")
elif (cpu == Java) and (player1 == Ruby):
print("The computer chose Java and you chose Ruby")
print("You won!")
while (player1 == Python,Ruby,Java):
print(pythonRubyJava())