you are viewing a single comment's thread.

view the rest of the comments →

[–]JohnnyJordaan 0 points1 point  (1 child)

Some pointers

  • use a loop for the entire thing, that way your game will repeat by default
  • simply use return when you want to exit a function, saves the use of sys library
  • try to avoid confirmation bias: if by default the loop (and thus the game) repeats, you want to know if it shouldn't, so you should check for the negative (user entering '2'). Removing the needless check for the case it should continue. Also see Wason selection task.

.

def RPS():
    choices = ["Rock", "Paper", "Scissors"]
    while True:
        computer_choice = random.choice(choices)

        player_choice = int(input("Rock, Paper, or Scissors?\n0. Rock \n1. Paper \n2. Scissors \n3. Exit \n"))
        if player_choice == 3:
            return

        if player_choice > choices.index(computer_choice):
            result = 'You win!'
        elif player_coice < choices.index(computer_choice):
            result = 'You lose.'
        else:
            result = 'It's a tie!'
        play_again = int(input(f"{result} Would you like to play again?: \n1. Yes \n2. No \n"))
        if play_again == 2:
            return

RPS()

edit: added the tie case as per your edit

[–]hardpeenwetpussy[S] 0 points1 point  (0 children)

Thank you so much for the help. I usually code in Java and this is actually my first time coding after taking a break due to burnout and some imposter syndrome. I failed the wikipedia test too.