PRoblem of range in def insert_ones(y, segment_end_ms)

Hi,

In the def function"def insert_ones", I tried to define the range. Unfortunately, I haven’t chosen the good range :
I have the mistake in insert_ones_test : AssertionError: It must insert exactly 50 ones

I wrote : for i in range(0, Ty-1):

Can you help me please ?

Please help me understand how the markdown and code comments are insufficient to complete insert_ones.

It’s possible to implement this without any for loops: you can use direct array indexing. But if you are using for loops, keep in mind that indexing and loop ranges in python are 0-based. Try running the following loop and watch what happens:

for ii in range(5):
    print(f"ii = {ii}")

print(f"After loop ii = {ii}")

Amazingly, my trouble is over the range syntaxis, I believe !
I don’t understand clearly… It seems so easy that I’m unable to find my mistakes.

The syntax is pretty simple. Maybe the problem is more in your intent. E.g. what does T_y have to do with 50? :nerd_face:

Thank you for your help !

1 Like