write code to simulate the game for one player and calculate the number of dice throws required to finish a game. The user should be allowed to specify the number of games simul
The code that you have written only rolls the dice one time. You need to keep rolling until you have won the game. It might be best to create a function that plays the game one time and returns the number of dice rolls needed.
def playGame():
counterPosition = 0
numberOfRolls = 0
while (counterPosition < 100):
numberOfRolls += 1
currentDiceroll = diceroll()
print("The currentDiceroll is", currentDiceroll)
counterPosition += currentDiceroll
# your if statements go here
return numberOfRolls
Then you can call this function however many times you want.
totalDiceRolls = 0
for i in range(userInput):
totalDiceRolls += playGame()
avgRolls = totalDiceRolls / userInput