@@ -49,7 +49,7 @@ def streak_tracker(flips_list=[], streak_of=3):
4949 that displays how many of each type of streak occurred. 
5050 """ 
5151 STREAKS  =  {'HEADS' : 0 , 'TAILS' : 0 } # Keep a dictionary to track counts. 
52-  HEAD_STREAKS , TAIL_STREAKS  =  (0 , 0 ) # Keep track of the type of streak and how many. 
52+  HEAD_STREAKS , TAIL_STREAKS  =  (0 , 0 ) # Keep track of the type of streak and how many. 
5353
5454 if  (flips_list  !=  []): # CASE: Nonempty list 
5555 previous  =  None 
@@ -69,14 +69,13 @@ def streak_tracker(flips_list=[], streak_of=3):
6969 elif  (current == 'T' ):
7070 STREAKS ['TAILS' ] +=  1 
7171 # CASE: Different than previous value 
72-  else :
72+  elif  ( current != previous ) :
7373 if  (current == 'H' ):
7474 STREAKS ['HEADS' ] =  1 
7575 elif  (current == 'T' ):
7676 STREAKS ['TAILS' ] =  1 
7777
78-  previous  =  flips_list [i - 1 ] # Store current as previous for next iteration 
79- 78+  previous  =  flips_list [i ] # Store current as previous for next iteration 
8079 return  {'HEAD STREAKS' : HEAD_STREAKS , 'TAIL STREAKS' : TAIL_STREAKS }
8180
8281 else : # CASE: Empty list 
@@ -86,7 +85,7 @@ def streak_tracker(flips_list=[], streak_of=3):
8685
8786# TESTS COMMENTED BELOW: 
8887''' 
89- coin_flip_results = coin_flips(10000 ) 
88+ coin_flip_results = coin_flips(1000 ) 
9089print(' '.join(coin_flip_results)) 
9190
9291sample = [ 'H', 'H', 'T', 'H', 'T', 'H', 'H', 'T', 'H', 'H', 'T', 'T', 'T', 'H', 'H', 'T', 'T', 'T', 'H', 'T', 'H', 'T', 'H', 'H', 'T',  
0 commit comments