Python if/elif/else条件语句

Python if/elif/else条件语句,python,conditional-statements,Python,Conditional Statements,我正在尝试创建一个非常简单的石头/布/剪刀游戏(我是python新手),我正在尝试理解为什么下面代码的结果总是“这是一个平局”。在我的代码中使用布尔“and”运算符时,我认为当两个条件都满足时,它会打印“youwin”。为什么不,我错过了什么?我已经看过这里的文档和谷歌使用的条件语句,从我发现我正确地使用了它们,但显然不是 rock = ''' _______ ---' ____) (_____) (_____) (____) ---.__

我正在尝试创建一个非常简单的石头/布/剪刀游戏(我是python新手),我正在尝试理解为什么下面代码的结果总是“这是一个平局”。在我的代码中使用布尔“and”运算符时,我认为当两个条件都满足时,它会打印“youwin”。为什么不,我错过了什么?我已经看过这里的文档和谷歌使用的条件语句,从我发现我正确地使用了它们,但显然不是

    rock = '''
    _______
---'   ____)
      (_____)
      (_____)
      (____)
---.__(___)
'''

paper = '''
    _______
---'   ____)____
          ______)
          _______)
         _______)
---.__________)
'''

scissors = '''
    _______
---'   ____)____
          ______)
       __________)
      (____)
---.__(___)
'''
import random

test_seed = int(input("Create a seed number: "))
random.seed(test_seed)


human_choice = input("What do you choose? Type 0 for rock, 1 for paper or 2 for scissors. ")
computer_choice = random.randint(0, 2)

if human_choice == 0:
  print(rock)
elif human_choice == 1:
  print(paper)
else:
  print(scissors)

print("Computer chose:")

if computer_choice == 0:
  print(rock)
elif computer_choice == 1:
  print(paper)
else:
  print(scissors)

if human_choice == 0 and computer_choice == 2:
  print("You win.")
elif human_choice == 1 and computer_choice == 0:
  print("You win.")
elif human_choice == 2 and computer_choice == 1:
  print("You win.")
elif computer_choice == 0 and human_choice == 2:
  print("You lose.")
elif computer_choice == 1 and human_choice == 0:
  print("You lose.")
elif computer_choice == 2 and human_choice == 1:
  print("You lose.")
else:
  print("It's a draw.")

非常简单:您没有将用户输入强制转换为整数值。。因为稍后将值与整数进行比较,所以需要对其进行强制转换,因为默认情况下,用户输入是字符串

只需更改以下代码行:

human_choice = input("What do you choose? Type 0 for rock, 1 for paper or 2 for scissors. ")
为此:

human_choice = int(input("What do you choose? Type 0 for rock, 1 for paper or 2 for scissors. "))

你需要将人类的选择转换为int