lundi 29 avril 2019

What is the proper syntax for multi-conditional if-statements in python?

I'm not having much luck grouping multiple if conditional statements in python.

try:     
  player1_input = input("Enter 1 for Rock, 2 for Paper, 3 for Scissors: ")
  player2_input = input("Enter 1 for Rock, 2 for Paper, 3 for Scissors: ")

  if (player1_input or player2_input) != ("1" or "2" or "3"):
    raise
except Exception:
  print("You did not enter a correct input")

From what I want to achieve, I would like to raise an exception if user 1 or 2 do not enter and input that is 1,2 or 3. However, when I try a test input of user1: 3 and user2: 1 a exception is incorrectly raised. How can I fix this issue? Any help would be greatly appreciated. I do believe I must have a misunderstanding of the syntax of multi-conditional if statements.

Aucun commentaire:

Enregistrer un commentaire