So I'm doing a little exercise project witch is supposed to make 100 random head and tails the check for every 6 streaks of head or tail then store it in a variable and repeat this process 10000 times
and I'm stuck at how to make the streaks counting system I have no Idea how to do it and I need help
For further actions, you may consider blocking this person and/or reporting abuse
Top comments (4)
Here’s what I thought when I saw your problem:
Make 100 random heads and tails → Maybe using a list comprehension like
[random.choice(['H', 'T']) for _ in range(100)]
?Check for every 6-streak of heads or tails and store the results
→ Probably by looping through the list, keeping a counter for consecutive matches, and resetting it when the flip changes.
Repeat this whole thing 10,000 times → So likely a
for _ in range(10000):
loop that runs the full logic each time.Print the results → Either the total number of experiments where a 6-streak was found, or the overall probability.
yes but the streak check is the only thing I have no idea how to make
here’s a small pattern that might help you think through the streak logic:
1
inrange(1, len(flips))
if you don't know what that does it’s worth looking up.This lets you compare each coin flip to the one before it. Then, you can start tracking how many times the same result appears in a row. That’s your "streak".
From there, think about:
thanks for your effort I'll try it and tell you how it went