0

So I am creating a program that checks the probability of someone flipping a coin 100 times, and how many times they get heads six times consecutively over the course of the 100 flips. I'm also repeating this 100 flip trial 10 times to get a better sample size. Here's the block of code I have to generate the lists for my 10 trials:

import random
numberOfStreaks = 0

for totalTrials in range(10):
    flipTrials = []
    for x in range(100):
        flip = random.randint(0,1)
        if flip == 1:
            flipTrials.append('H')
        if flip == 0:
            flipTrials.append('T')

Here's what I initially wrote to try to search for the six consecutive head flips within each trial. I threw in the print statement to see if the numberOfStreaks variable was incrementing, but after executing the program it returned 0. I also tried creating a separate list for the consecutive head flips to use instead of the string and had the same issue. What am I missing?

    if "'H', 'H', 'H', 'H', 'H', 'H'" in flipTrials:
        numberOfStreaks += 1
        print(numberOfStreaks)
0xChris
  • 3
  • 1

0 Answers0