I am very new to Python and coding in general. I tried to create my own Rock, Paper, Scissors game. The issue I'm getting can be tested by doing the following: typing "rock", then typing "yes" to play again and repeating those two steps. Eventually, it gives me an "Invalid Input." It is only supposed to print this if the user types something besides rock, paper, or scissors. Is there any way I can fix this? I'd really appreciate any input and advice. Thank you for your time.
import random
# to loop the program
def Repeat():
Answer = input ("Do you want to play again? (Y/N): ")
if Answer == ("Yes") or Answer == ("yes") or Answer == ("Y") or Answer == ("y"):
Game()
if Answer == ("No") or Answer == ("no") or Answer == ("N") or Answer == ("n"):
exit()
else:
print ("Invalid Input")
Repeat()
def Game():
# Variable Reset
Choice = None
Opponent_Choice = None
# Choices
Opponent_Choices = ["Rock", "Paper", "Scissors"]
Choice = input ("Type Rock, Paper, or Scissors: ")
Opponent_Choice = random.choice(Opponent_Choices)
# Outcomes
# if you choose rock
if Choice == "Rock" or Choice == "rock":
if Opponent_Choice == "Paper":
print ("your opponent chose Paper. You lose!")
Repeat()
elif Opponent_Choice == "Scissors":
print ("your opponent chose Scissors. You win!")
Repeat()
elif Opponent_Choice == "Paper":
print ("your opponnent chose Rock. It was a tie!")
Repeat()
# if you choose paper
elif Choice == "Paper" or Choice == "paper":
if Opponent_Choice == "Paper":
print ("your opponent chose Paper. It was a tie!")
Repeat()
elif Opponent_Choice == "Scissors":
print ("your opponent chose Scissors. You lose!")
Repeat()
elif Opponent_Choice == "Paper":
print ("your opponent chose Rock. You win!")
Repeat()
# if you choose scissors
elif Choice == "Scissors" or Choice == "scissors":
if Opponent_Choice == "Paper":
print ("your opponent chose Paper. You win!")
Repeat()
elif Opponent_Choice == "Scissors":
print ("your opponent chose Scissors. It was a tie!")
Repeat()
elif Opponent_Choice == "Paper":
print ("your opponet chose Rock. You lose!")
Repeat()
else:
print ("Invalid input")
Game()
Game()
p.s. Sorry for the messy code :P Still very new to this.
