My code is executing mostly how I want it to but when it prints my values from my function it is doubling the amount of times that the function code is ran. I only want 10 interations but it is printing 20. I would just lower the range to 5 but then it throws off my final score in my block of code that displays who won the most rounds. How can I stop the function code from running twice? TIA
import random
import time
answer = input("Play the game?")
winsP1 = 0
winsP2 = 0
def determineWinner(winsP1, winsP2):
for wins in range(10):
from random import randint
player1 = randint(1,10)
player2 = randint(1,10)
#time.sleep(1)
print("Player 1:", player1)
#time.sleep(1)
print("Player 2:", player2)
#time.sleep(1)
if player1==player2:
print("This round is a tie!")
winsP1 += 1
winsP2 += 1
elif player1>player2:
print("Player 1 wins this round!")
winsP1 += 1
elif player2>player1:
print("Player 2 wins this round!")
winsP2 += 1
return winsP1, winsP2
winsP1, winsP2 = determineWinner(winsP1 = winsP1, winsP2 =
winsP2)
if answer == "y" or answer == "Y" or answer == "yes" or answer == "Yes":
determineWinner(winsP1, winsP2)
if winsP1>winsP2:
print()
print("The score totals are:")
print("Player one: " + str(winsP1))
print("Player two: " + str(winsP2))
print()
print("Player 1 wins with a score of", str(winsP1) + "!")
print()
elif winsP2>winsP1:
print()
print("The score totals are:")
print("Player One: " + str(winsP1))
print("Player two: " + str(winsP2))
print()
print("Player 2 wins with a score of", str(winsP2) + "!")
print()
elif winsP1==winsP2:
print()
print("The score totals are:")
print("Player one: " + str(winsP1))
print("Player two: " + str(winsP2))
print()
print("It's a tie!")
print()