#๐Ÿ”’ Rock Paper Scissors error

19 messages ยท Page 1 of 1 (latest)

void ice
#

for some reason even tho i hav it set right this happens: Rock, Paper, or Scissors? Paper You chose: Paper Computer chose: Scissors Draw anyone who has played rock, paper, scissors knows what's wrong

Here is my code
`import time
import random

num = random.randrange(1, 4)

if num == 1:
play = "Rock"
elif num == 2:
play = "Paper"
elif num == 3:
play = "Scissors"

print("Welcome To the game ")

time.sleep(0.5)

choice = input("Rock, Paper, or Scissors?")

if choice == "Rock" or choice == "rock" and play == "Rock" or play == "rock":
status = "Draw"

elif choice == "Paper" or choice == "paper" and play == "Paper" or play == "paper":
status = "Draw"

elif choice == "Scissors" or choice == "scissors" and play == "Scissors" or play == "scissors":
status = "Draw"

elif choice == "Rock" or choice == "rock" and play == "Scissors" or play == "scissors":
status = "Win"

elif choice == "Paper" or choice == "paper" and play == "Rock" or play == "rock":
status = "Win"

elif choice == "Scissors" or choice == "scissors" and play == "Paper" or play == "paper":
status = "Win"

elif choice == "Scissors" or choice == "scissors" and play == "Rock" or play == "rock":
status = "Lose"

elif choice == "Rock" or choice == "rock" and play == "Paper" or play == "Paper":
status = "Lose"

elif choice == "Paper" or choice == "paper" and play == "Scissors" or play == "scissors":
status = "Lose"

print("You chose:", choice, "Computer chose:", play, )
print(status)`

stone havenBOT
#

@void ice

Python help channel opened

Remember to:

  • Ask your Python question, not if you can ask or if there's an expert who can help.
  • Show a code sample as text (rather than a screenshot) and the error message, if you've got one.
  • Explain what you expect to happen and what actually happens.

:warning: Do not pip install anything that isn't related to your question, especially if asked to over DMs.

bright rain
#

!e


choice = "Paper"
play = "paper"
print(choice == "Paper" or choice == "paper" and play == "Scissors" or play == "scissors")

stone havenBOT
bright rain
#

ok that's what I thought

#

look at your conditions

#

A or B and C or D is equivalent to:

A or (B and C) or D

#

you want:

(A or B) and (C or D)

#

You have two options: 1) place the parentheses to make it behave like you want
2) modify the choice to not take into account the case

#

Also remember what values can play take

bright rain
#

one of the two is much easier, both will work fine

void ice
#

Could you explain how to do the easier option? If you doint mind!

bright rain
#

I think it will be too much spoonfeeding

#

To not take into account the case, you need to transform everything into the same case (lower or upper). So instead of checking for "Paper" or "paper", only check for "paper" (or for "PAPER")

#

the other one is simply adding some parentheses

void ice
#

ok ty!

stone havenBOT
#
Python help channel closed for inactivity

This help channel has been closed. Feel free to create a new post in #1035199133436354600. To maximize your chances of getting a response, check out this guide on asking good questions.