在制作剪刀石头布游戏时得到意想不到的结果
Got unexpected results while creating rock, paper and scissor game
我正在制作剪刀石头布游戏。
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")
我不知道这有什么问题,但我无法获得胜利。我所有的结果都是“你输了”,
虽然我包括了我所有的获胜可能性。
computer_choice
是 list
的一个元素(顺便说一句,这是一个 糟糕的 名称),因此永远不会等于任何数字。
我正在制作剪刀石头布游戏。
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")
我不知道这有什么问题,但我无法获得胜利。我所有的结果都是“你输了”, 虽然我包括了我所有的获胜可能性。
computer_choice
是 list
的一个元素(顺便说一句,这是一个 糟糕的 名称),因此永远不会等于任何数字。