I am a newer programmer. I am trying to build the infamous rock-paper-scissors game. I am working on making infinite loops, break statements and making the game print out the winner and prompt the user to play again. However, I am having trouble with prompting the user to play again. No matter the answer the user inputs, the program will start again. I am not sure what I'm doing wrong.
Here is the code:
#defining the game function
def game():
while True:
p1=input("Player 1,Rock, Paper, or Scissors?: \n")
p2= input("Player 2, what's your play?: \n")
if p1 == "rock":
if p2 == "scissors":
print ("player 1 wins")
elif p2 == "paper":
print ("player 2 wins")
elif p1== "paper":
if p2 == "rock":
print ("player 2 wins")
elif p2 == "scissors":
print ("player 1 wins")
elif p1 == "scissors":
if p2 =="rock":
print ("player 2 wins")
elif p2 == "paper":
print ("player 1 wins")
else:
p1 == p2
print ("its a tie")
#ask the user if they'd like to play again
#the issue is in this section of code
#no mater what the input is, the program will always prompt and start the function again
ask= input("do you want to play again?: \n")
if ask == 'y' or 'yes':
game()
else:
ask == 'n' or 'no'
print ("game over")
break
#run program
game()
#output
#Player 1,Rock, Paper, or Scissors?:
#rock
#Player 2, what's your play?:
#paper
#player 2 wins
#do you want to play again?:
#n
#Player 1,Rock, Paper, or Scissors?:
I've tried reversing the y and n prompts but this just reverses the problem (makes the game end regardless of the input). I've tried to change the formatting as well, but that always results in an error. Any help would be greatly appreciated.