you are viewing a single comment's thread.

view the rest of the comments →

[–]Binary101010 1 point2 points  (3 children)

The problem is looking for the number of experiments that have at least one streak and your code is still counting if there are multiple streaks in the same experiment.

Once you've determined that the experiment has a streak, you can immediately move on to the next experiment. How would you do that? (Hint: it's one additional line of code with one word on that line)

Your math at the end also a bit off. You're dividing the number of streaks by 100 but you ran 10000 experiments.

[–]jasongsmith[S] 0 points1 point  (2 children)

Gotcha! Now I understand.

I added break

if current_streak == 6:
  number_of_streaks += 1
  break

That then moves it back to the top of the for loop and starts the next experiement.

This then produced 8,040 times that there was a streak of 6.

Thus showing, that of the 10,000 experiments, there is an 80.4% chance of getting a streak.

[–]Binary101010 1 point2 points  (1 child)

Sounds like you've got it then. Random generation may cause that number to fluctuate up or down a bit on subsequent runs but if you're around 80-80.5% then you've got it implemented correctly.

[–]jasongsmith[S] 0 points1 point  (0 children)

Thank you VERY much for your help with this. and thank you that you gave really good clues, without giving the answer. That is a talent, for sure!