Hey I'm completely new to Python, only been using it for 2 days, and relatively new to programming. I'm trying to create a Rock, Paper, Scissors game. My problem is that when I run the program and I insert 'quit' (which is supposed to exit the program) the program keeps running, and I have no idea why. Any ideas? This is my code:
from random import randint
#the computer's hand
def ran_number():
comp_choice = randint(1, 3)
if comp_choice == 1:
hand = "rock"
elif comp_choice == 2:
hand = "paper"
else:
hand = "scissors"
return hand
#game starts
def play_game():
print("Let's play a game of Rock, Paper, Scissors!")
while True:
choice = input("Type: 'rock', 'paper', or 'scissors' to play, or 'quit' to end the game.")
choice.lower()
comp = ran_number()
if choice == 'quit':
print("\nIt's been a pleasure to play against you! Hope to see you another time.")
break
elif ((choice == 'rock' and comp == 'paper') or (choice == 'paper' and comp == 'scissors') or (choice == 'scissors' and comp == 'rock')):
print("\n{} beats {}! You lose!".format(comp.capitalize(), choice.capitalize()))
play_game()
continue
elif choice == comp:
print("\nYou both played {}. It's a tie!".format(choice.capitalize()))
play_game()
continue
else:
print("\n{} beats{}! You win!".format(choice.capitalize(), comp.capitalize()))
play_game()
continue
play_game()