first post, sorry if it doesn't fit the criteria or if there are similar questions. I googled before posting here and was not able to find anything about this. I'm learning python and created a very basic rock, paper, scissors game. I wanted the script to ask the user if he wants to replay the game at the end and I looked up how to do so, as I was stumped.
The script below, more specifically the while loop completely skips the elif statement and regardless if I type Y or y, it just says "ciaox" and ends. If it do it the other way around, it skips the elif statement and just restarts the game anyway.
Help would be appreciated.
import random
def game():
sl = ["rock", "paper", "scissors"]
us = input("Rock, paper, scissors?: ")
sl.remove(us)
pcs = random.choice(sl)
if us == "rock" and pcs == "paper":
print("You chose " + us + ". PC chose " + pcs + ". You lose.")
elif us == "rock" and pcs == "scissors":
print("You chose " + us + ". PC chose " + pcs + ". You win.")
if us == "paper" and pcs == "rock":
print("You chose " + us + ". PC chose " + pcs + ". You win.")
elif us == "paper" and pcs == "scissors":
print("You chose " + us + ". PC chose " + pcs + ". You lose.")
if us == "scissors" and pcs == "rock":
print("You chose " + us + ". PC chose " + pcs + ". You lose.")
elif us == "scissors" and pcs == "paper":
print("You chose " + us + ". PC chose " + pcs + ". You win.")
while True:
game()
replay = input("Would you like to play again? Y/N ")
if replay == "N" or "n":
print ("ciaox")
break
elif replay == "Y" or "y":
game()