Below is the code that I have built for the dice game i made. I need it to display the number of wins and the number of losses once i quit the game. Everything is running smoothly, but it is only counting the last result currently. any ideas why?
import random
def roll_dice():
winner = 0
loser = 0
roll = (random.randint(1,6))
roll2 = (random.randint(1,6))
print(roll," "roll2)
if roll == roll2:
print("Winner!")
winner += 1
else:
print("Loser!")
loser += 1
play_again = input("Would you like to play again?")
if play_again == "yes":
roll_dice()
else:
print("You won " , winner , "times")
print("You lost ", loser , "times")
quit
def main():
game_start = input("Would you like to roll the dice?")
if game_start == 'yes':
roll_dice()
else:
print("too bad")
if __name__ == '__main__':
main()