Exercise 7: Flip the coin // Advanced - error messages
Hi everyone,
this is a really fun & interesting course! Thanks to the creators for sharing it with everyone!
I am currently working on exercise 7 at the advanced level and need some help because I am stuck. Please advise :)
My code works as follows:
The generate function uses the following statement and returns the result as the variable seq:
seq = np.random.choice([0, 1], p=[1-p1, p1], size=10000)This is used in the count function as input, where I loop through packs of 5 numbers in the sequence and check if the sum is 5. If yes, my counter is increased by 1. It looks as follows:
counter = 0
for i in range(0,len(seq) - 4):
sum_check = np.sum(seq[i:i+5])
if sum_check == 5:
counter += 1
return counterMain function and print statement are as provided in the exercise.
When I test the code, it returns values close to 1316, which look good. However, when submitting the code, I get the attached error statement. What is the problem in my code that I do not see? Can someone please help?
Thanks in advance
Alex