how can restart program? trying find sum of first set of data in first loop , sum of data in second loop alone, sum in last loop calculates sum of data in loop , 1 before. mistake did make?
import random, time #variables die1 = 0 die2 = 0 goal = 0 tries1 = 0 tries2 = 0 sum = 0 #asking player's names player1 = input("what name, player1?") player2 = input("what name, player2?") #the "goal" goal = random.randrange(5) + 1 print("the goal is:", goal) while die1 != goal: die1 = random.randrange(5) + 1 print(player1, "your roll is:", die1) tries1 = tries1 + 1 sum = sum + die1 print(sum) while die2 != goal: die2 = random.randrange(5) + 1 print(player2, "your roll is:", die2) tries2 = tries2 + 1 sum = sum + die2 print(sum)
you missing re-initializing sum 0 after first loop.