我試圖在Python中製作一個搖滾,紙張,剪刀的遊戲,我想我幾乎擁有它,但是我的代碼並沒有給我任何回報。我希望也許有人能幫助我。我的代碼將從沒有問題開始,並從用戶那裏獲得輸入,但是一旦用戶放入了一些內容,只是在幕後進行比較,並且不會返回一個聲明。誰能幫忙? (這也是一個賦值爲我的計算機科學類,所以我的老師是老生常談,並希望我們能夠運行它從Python,Ruby,Java的)Python中的岩石,紙張,剪刀3
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())
Downvote for「Python 4」 –
說謊!讓我對Python 4000 –
@ user2799617有點興奮已經糾正,所以downvote已經過時了。 – glglgl