# This program simulates rolling a 6-sided die repeatedly # a given number of times, stopping if a 1 is seen. import random # Rolls a 6-sided die the given number of times, returning the # sum of the rolls. If a 1 is seen, stops immediately and returns 0. def dice_roll(times): total = 0 for i in range(times): die = random.randint(1, 6) print(die) if die == 1: return 0 # stop immediately else: total += die return total # never rolled a 1 def main(): total = dice_roll(5) print("total is:", total) main()