我正在創建一個石頭、紙和剪刀的游戲。
rock = '''
_______
---' ____)
(_____)
(_____)
(____)
---.__(___)
'''
paper = '''
_______
---' ____)____
______)
_______)
_______)
---.__________)
'''
scissors = '''
_______
---' ____)____
______)
__________)
(____)
---.__(___)
'''
#Write your code below this
import random
list = [rock, paper, scissors]
choice = int(input("What do you choose? Type 0 for Rock, 1 for Paper or 2 for Scissors.\n"))
my_choice = list[choice]
print (my_choice)
computer_choice = list[random.randint(0,2)]
print("Computer chose:")
print(computer_choice)
if my_choice == computer_choice:
print('its a draw')
elif my_choice == 0 and computer_choice == 2 :
print("You won")
elif my_choice == 1 and computer_choice == 0 :
print ("You won")
elif my_choice == 2 and computer_choice == 1 :
print ("You won")
else :
print ("You lose")
我不知道這有什么問題,但我無法贏得勝利。我所有的結果都是“你輸了”,盡管我包括了我所有獲勝的可能性。
uj5u.com熱心網友回復:
computer_choice是list(這是一個可怕的名字,順便說一句)的一個元素,因此永遠不會等于任何數字。
轉載請註明出處,本文鏈接:https://www.uj5u.com/gongcheng/419774.html
標籤:
上一篇:使用R將串列轉換為串列串列
