##### Code review of my rock paper scissors game
 Code review of my rock paper scissors game Milan Programmer named Tim Posts: 10 Threads: 4 Joined: Sep 2020 Reputation: May-25-2022, 06:59 AM Hello team, I would like to submit my rock paper scissors game for code review. Any suggestion on how to improve it is more than welcome. ```import sys from random import randint # Game instructions, should be displayed before every user input def startgame(): print( ''' What do you want to play: [0] Rock [1] Paper [2] Scissors [9] Quit ''') # Checks if input is between 0 and 2 def inputValidation(userInput): while userInput not in [0, 1, 2, 9]: print(errorMessage) try: startgame() userInput = float(input(prompt)) except: print(errorMessage) startgame() continue if userInput == 9: sys.exit() if userInput in [0, 1, 2]: break return userInput # Compares user's input with computer's input def result(ValidatedInput, computerMove): moves = {0:'Rock', 1:'Paper', 2:'Scissors'} print(f'You played: {moves[ValidatedInput]}\nComputer played: {moves[computerMove]}') w = 'You Win!' l = 'You Lose!' if ValidatedInput == computerMove: print("It's a draw") elif ValidatedInput == 0 and computerMove == 1: print(l) elif ValidatedInput == 0 and computerMove == 2: print(w) elif ValidatedInput == 1 and computerMove == 0: print(w) elif ValidatedInput == 1 and computerMove == 2: print(l) elif ValidatedInput == 2 and computerMove == 0: print(l) elif ValidatedInput == 2 and computerMove == 1: print(w) prompt = '> ' errorMessage = 'Incorrect input, please input one of the provided options' #Game starts from here while True: computerMove = randint(0, 2) while True: try: startgame() userInput = int(input(prompt)) except: print(errorMessage) continue else: break if userInput == 9: break ValidatedInput = inputValidation(userInput) result(ValidatedInput, computerMove) continue_input = input('Play again [y/n]? ').upper() while continue_input not in 'YyNn': print('Incorrect input, please type y or n') continue_input = input((prompt)) if continue_input == 'N': c = False``` Reply

 Possibly Related Threads… Thread Author Replies Views Last Post Rock paper Scissors Milan 2 1,611 Feb-01-2021, 03:42 PM Last Post: Milan First time python user - Calculator code review Steamy 1 1,226 Jul-22-2020, 05:59 PM Last Post: Larz60+ 2nd Project: Rock, Paper, Scissors MiNigle 3 1,541 Jun-05-2020, 12:50 PM Last Post: MiNigle Rock Paper Scissors Game NectDz 5 1,982 May-31-2020, 12:40 PM Last Post: NectDz

Forum Jump:

### User Panel Messages

##### Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020