Coin toss probability
    import random
    from collections import Counter
    import itertools
    
    ##method for coin toss
    def cointoss():
        rand_i = random.randint(0, 1)
        outcomes = ["Heads", "Tails"]
        #outcomes = [0,1]
        return outcomes[rand_i]
    
    #create list
    list=[]
    
    ##Number of coin tosses
    n=3
    
    ##calls method and adds to the list
    for i in range(0, n):
        t1 = cointoss()
        list.append(t1)
    
    print(list)
    Counter(list)
    print(Counter(list))
    
    ##compare previous coin tosses with the last
    for index, i in enumerate(list):
        for j in list[index+1:]:
            print("list item i "+str(i))
            print("list item j " + str(j))
    
            if i==j:
                print("Same")
            else:
                print("Not the same")

&amp;#x200B;

I'm trying to edit this code so that it outputs the number of times a certain side occurs in a row.

&amp;#x200B;

So for example, a person makes ten coin toss, how many times does heads occur three times or two times in a row.

&amp;#x200B;

Any suggestions on how to edit it?