When I run this code and input "r" "p" or "s" the first if condition within the function runs as though it is true. My goal is for the else statement to run when the user inputs a valid answer, such as "s" "p" or "r". Tried debugging, calling the global choice variable, not sure what to do here. Help would be appreciatd. This is Python 3.7.
possible_options = ["rock", "paper", "scissors"]
choice = input("Enter r for rock, p for paper, and s for scissors: ")
def game():
global choice
print(choice)
if choice != "r" or choice != "p" or choice != "s":
choice = input("Invalid choice. Must be r, p, or s: ")
game()
else:
selection = choice
if selection == "r":
if random.choice(possible_options) == "rock":
print("The computer chose rock!")
print("It was a tie!")
elif random.choice(possible_options) == "paper":
print("The computer chose paper!")
print("Paper covers rock! You lose.")
elif random.choice(possible_options) == "scissors":
print("The computer chose scissors!")
print("Rock smashes scissors! You win!")
elif selection == "p":
if random.choice(possible_options) == "rock":
print("The computer chose rock!")
print("Paper covers rock! You win!")
elif random.choice(possible_options) == "paper":
print("The computer chose paper!")
print("It was a tie!")
elif random.choice(possible_options) == "scissors":
print("The computer chose scissors!")
print("Scissors cut paper! You lose.")
elif selection == "s":
if random.choice(possible_options) == "rock":
print("The computer chose rock!")
print("Rock smashes scissors! You lose.")
elif random.choice(possible_options) == "paper":
print("The computer chose paper!")
print("Scissors cut paper! You win!")
elif random.choice(possible_options) == "scissors":
print("The computer chose scissors!")
print("It was a tie!")
game()