Quote:I have generated the number between 1 to 6 using the randint() but now I want to know how many times the 66 are generated.
Think about the problem, what do you need to solve the problem by hand?
You do,'t need to keep a list of all dice drawing, all you need is to keep track of last dice.
If LastDice is 6 and NewDice is 6 then it is a 66
LastDice takes the value of NewDice
Try this change
for i in range(trial-1):
new_dice = randint(1, 6)
if last_dice == 6 and new_dice == 6:
counter += 1
last_dice = new_dice
Advice: try to draw more than 6 dices, at least for testing purpose. 36 draw of dice gets a reasonable odd to get a couple of 66.
Quote:I increased the no of draws to 100 and 666 are also being counted as 2 in counter....
When you encounter a 66, After increment
, change the
to another value to make sure it will not be used again.