Aug-27-2020, 03:31 PM
I am following a tutorial for a rock paper scissor game and I made some changes to it to stray from the tutorial. Everything works except for the fact that sometimes the random choice doesn't appear to pick a choice and the score is not tabulated.
Here's the code I have, please help me identify what is going wrong:
Here's the code I have, please help me identify what is going wrong:
import random import sys print("Rock, Paper, Scissors") wins = 0 losses = 0 ties = 0 while True: print('%s Wins, %s Losses, %s Ties' % (wins, losses, ties)) while True: playermove = input( "Enter your move: r(ock), (p)aper, (s)cissors or q(uit): ") if playermove == "q": print("Thanks for playing!") sys.exit() if playermove == "r" or playermove == "p" or playermove == "s": break else: print("Please type a valid character.") if playermove == "r": print("Rock versus...") if playermove == "S": print("Scissors versus...") if playermove == "p": print("Paper versus...") choices = ("r", "s", "P") compmove = random.choice(choices) if compmove == "r": print("Rock") elif compmove == "s": print("Scissors") elif compmove == "p": print("Paper") if playermove == compmove: print("It is a tie!") ties += 1 elif playermove == "r" and compmove == "s": print("You win!") wins += 1 elif playermove == 'p' and compmove == 'r': print('You win!') wins += 1 elif playermove == 's' and compmove == 'p': print('You win!') wins += 1 elif playermove == 'r' and compmove == 'p': print('You lose!') losses += 1 elif playermove == 'p' and compmove == 's': print('You lose!') losses += 1 elif playermove == 's' and compmove == 'r': print('You lose!') losses += 1