I've just started in Python and I'm programming a function that performs a sum of various rolls of the dice: import random
print("Comienzo")
total = 0
for i in range(3):
dado = random.randrange(1, 7)
print(f"Tirada {i + 1}: {dado}")
total += dado
print(f"En total ha obtenido {total} punto(s).")
print("Final")
How can I make the number of rolls stop only when the total has reached 100 points?
Following your code, to roll a single die in each move you just have to change the
for
for awhile
.Now what you may want is to roll 3 dice on each play, so you put the
for i in range(3):
inside thewhile
.Option 1:
Option 2