-1

If user inputs a correct word uppercase I get a "You made a mistake" response. Why does user_choice.lower() not work like I intended? Where did I make a mistake?

import random

rock_paper_scissors = ("rock", "paper","scissors")
cpu_choice = random.choice(rock_paper_scissors)
user_choice = input("Rock, paper or scissors ? Enter your choice: ")


if user_choice.lower() != "rock" or "paper" or "scissors":
    print("You made a mistake. Please try again")
    user_choice = input("Rock, paper or scissors ? Enter your choice: ")

while cpu_choice == user_choice.lower():
    print ("--------------------------------------------------------")
    print(f"CPU: {cpu_choice.upper()} vs YOU: {user_choice.upper()}.  It's a tie. Try again!")
    print ("--------------------------------------------------------")
    user_choice = input("Rock, paper or scissors ? Enter your choice: ")
quamrana
  • 37,849
  • 12
  • 53
  • 71
nisanosa
  • 3
  • 2

2 Answers2

2

Did you mean:

if user_choice.lower() not in rock_paper_scissors:
    print("You made a mistake. Please try again")
quamrana
  • 37,849
  • 12
  • 53
  • 71
  • Maybe even better: `if user_choice.lower() not in rock_paper_scissors:`, so we don't have to write those values again. With just three values performance is not an issue. – Matthias Dec 14 '20 at 15:15
1

The condition if you set isn't correct. Try instead

if user_choice.lower() != "rock" or user_choice.lower() != "paper" or user_choice.lower() != "scissors":
mhhabib
  • 2,975
  • 1
  • 15
  • 29