mardi 15 janvier 2019

Is there a simple loop for rolling 6 dice until atleast 4 are the same number?

The question reads like this "Create a program that simulates the roll of a die. Have the program output the rolls of six dice repeatedly until at least four of the dice roll the same number."

I've come so far to where I just need the loop to make the dice continue rolling until they get the same as the first dice. I'm new to Python so I've tried reading about loop and I've tried some but it wouldn't work.

roll1 = random.choice(dice)    
print(roll1)    
roll2 = random.choice(dice)    
if roll2 == roll1:    
    print(roll2)

The outcome I want is that it rolls the first dice, then the second dice, and if it's the same it prints the second dice and continues to the third dice, but if it's different it will roll again until it's the same.

Aucun commentaire:

Enregistrer un commentaire