I need to make the second python loop start following where the iterator of the first loop is at the entry into the second loop
Currently both loops run the entire range
Unfortunately I don't understand this syntax
Full code in the example is here: https://gist.github.com/kylemcdonald/c8e62ef8cb9515d64df4
for i, (start1, stop1) in enumerate(zip(starts, stops)):
audio1 = y[start1:stop1]
for j, (start2, stop2) in enumerate(zip(starts, stops)):
audio2 = y[start2:stop2]
I tried changing to
for i, (start1, stop1) in enumerate(zip(starts, stops)):
audio1 = y[start1:stop1]
for j, (start2, stop2) in enumerate(zip(start1, stops)):
audio2 = y[start2:stop2]
But i get the error: zip argument #1 must support iteration
I also tried the obvious way it would be done in C
for i, (start1, stop1) in enumerate(zip(starts, stops)):
audio1 = y[start1:stop1]
for j = i+1, (start2, stop2) in enumerate(zip(start1, stops)):
audio2 = y[start2:stop2]
But i get the error: SyntaxError: invalid syntax
Im not a python programmer, please help me understand and fix this complex syntax so that loop2 begins at the iterator following the current iterator of loop 1 and goes to the end of the loop
So there are no repeated comparisons and no 2 of the same audio samples are compared to each other
Thanks,
This might be what you want:
for i, (start1, stop1) in enumerate(zip(starts, stops)):
audio1 = y[start1:stop1]
for start2, stop2 in zip(starts[i+1:], stops[i+1:]):
audio2 = y[start2:stop2]
which iterates over starts / stops from the current value of i. I removed the second enumerate, as for your question you don't need to produce indexes.