title: To find what percentage of the coin flips contains a streak of six heads or tails in a row?
body: <p>I was doing practice problems from 'Automate the Boring Stuff with Python' and I came across this question.
  Write a program to find out how often a streak of six heads or a streak of six tails comes up in a randomly generated list of heads and tails.</p>
  
  <p>1.the first part generates a list of randomly selected 'heads' and 'tails' values
  2.the second part checks if there is a streak in it.</p>
  
  <p>Put all of this code in a loop that repeats the experiment 10,000 times so we can find out what percentage of the coin flips contains a streak of six heads or tails in a row.</p>
  
  <p>Here what i have done till now : </p>
  
  <pre><code>import random
  myList = []
  n = int(input('How many times do you want to toss the coin : '))
  i = 0
  while i &lt;= n :
      outcome = random.randint(0,1)
      if outcome == 0 :
          toss = 'H'
          myList.append(toss)
      elif outcome == 1 :
          toss = 'T'
          myList.append(toss)
      i += 1
  
  headStreak = 0
  total_H_Streak = 0
  
  for i in myList :
      if i == 'H' :
          headStreak += 1
          if headStreak == 6 :
              total_H_Streak += 1
      else :
          headStreak = 0
  print('The streak of 6 heads in a row is : ',total_H_Streak)
  tailStreak = 0
  total_T_Streak = 0
  for j in myList :
      if j == 'T' :
          tailStreak += 1
          if tailStreak == 6 :
              total_T_Streak += 1
      else :
          tailStreak = 0
  print('The Streak of 6 tails in a row is : ',total_T_Streak)
  </code></pre>
  
  <p>Although I think this code is correct, I was wondering if there is any other approach to this problem.
  Any suggestion is appreciated.</p>