Feb-13-2022, 08:11 PM
(This post was last modified: Feb-13-2022, 09:03 PM by RoadToSensei.)
I am having a hard time programming a Rock Paper Scissors Code:
I use a while loop to limit the user to only input [R]ock [P]aper [S]cissors or [Q]uit
However, when inputting a value outside the R P S or Q range. The code still runs and returns the computer value.
How can I properly limit the user to only input R P S or Q?
Why does my while statement not properly limit the inputs?
import random, sys Wins = int() Losses = int() Ties = int() print ('Lets play Rock, Paper, Scissors!') print ("0 Wins, 0 Losses, 0 Ties") print ("Enter your move: (R)ock (P)aper (S)cissors or (Q)uit") Player = input() while Player == "R" or "P" or "S" or "Q": if Player == "R": print ("ROCK vs...") elif Player == "P": print ("PAPER vs...") elif Player == "S": print ("SCISSOR vs...") elif Player == "Q": print ("Thanks for playing, sore loser") sys.exit()
I use a while loop to limit the user to only input [R]ock [P]aper [S]cissors or [Q]uit
However, when inputting a value outside the R P S or Q range. The code still runs and returns the computer value.
How can I properly limit the user to only input R P S or Q?
Why does my while statement not properly limit the inputs?