and i made a rock paper scissor game, but when i loose a life or win, it keep on spamming the same message can anyone help
import random #this allows me to generate random numbers
def main(): #all the main code is under this
print ("Hello Welcome to my Rock, Paper and Scissors game!") #welcome message
count = 0 #This counts how many tries you tried
while count != 3: #You can only try 3 times
print ("Please choose whether:") #allows the user to choose between rock, paper and scissors
print ("[1] Rock")
print ("[2] Paper")
print ("[3] Scissors")
user_choice = int(input()) #saves user input into a variable
if user_choice == 1:
user_choice = ("Rock")
elif user_choice == 2:
user_choice = ("Paper")
elif user_choice == 3:
user_choice = ("Scissors")
elif user_choice > 3:
print ("Invalid choice!")
print ("Restarting...")
main()
computer_choice = random.randint(1,3) #generates random number between 1 and 3
if computer_choice == 1: #define 1,2 and 3
computer_choice = ("Rock")
elif computer_choice == 2:
computer_choice = ("Paper")
elif computer_choice == 3:
computer_choice = ("Scissors")
def choice_1():
score = 0
lives = 2
if user_choice == "Rock":
if user_choice == computer_choice:
print ("You chose:",user_choice)
print ("--------VS--------")
print ("Computer chose:",computer_choice)
print ("Draw!")
elif user_choice == "Rock" and computer_choice == "Paper":
print ("You chose:",user_choice)
print ("--------VS--------")
print ("Computer chose:",computer_choice)
print ("You lost!")
lives = lives - 1
elif user_choice == "Rock" and computer_choice == "Scissors":
print ("You chose:",user_choice)
print ("--------VS--------")
print ("Computer chose:",computer_choice)
print ("You Won!")
score = score + 1
if user_choice == "Paper":
if user_choice == computer_choice:
print ("You chose:",user_choice)
print ("--------VS--------")
print ("Computer chose:",computer_choice)
print ("Draw!")
elif user_choice == "Paper" and computer_choice == "Scissors":
print ("You chose:",user_choice)
print ("--------VS--------")
print ("Computer chose:",computer_choice)
print ("You lost!")
lives = lives - 1
elif user_choice == "Paper" and computer_choice == "Rock":
print ("You chose:",user_choice)
print ("--------VS--------")
print ("Computer chose:",computer_choice)
print ("You Won!")
score = score + 1
if user_choice == "Scissors":
if user_choice == computer_choice:
print ("You chose:",user_choice)
print ("--------VS--------")
print ("Computer chose:",computer_choice)
print ("Draw!")
elif user_choice == "Scissors" and computer_choice == "Rock":
print ("You chose:",user_choice)
print ("--------VS--------")
print ("Computer chose:",computer_choice)
print ("You lost!")
lives = lives - 1
elif user_choice == "Scissors" and computer_choice == "Paper":
print ("You chose:",user_choice)
print ("--------VS--------")
print ("Computer chose:",computer_choice)
print ("You Won!")
score = score + 1
print ("You have",lives,"lives left")
while lives != 0:
choice_1()
else:
print ("oops! you ran out of lives")
print ("Restarting...")
main()
count = count + 1
choice_1()
else:
print ("Thanks for playing!")
if score == 3:
print ("Fantastic! you scored:",score,"/3")
elif score == 2:
print ("Good job! you scored:",score,"/3")
elif score == 1:
print ("Not bad! you scored:",score,"/3")
elif score == 0:
print ("Unlucky! you scored:",score,"/3")
main()