Use the for loop to iterate from 0th element to penultimate element and compare the signs or check if the product of 2 consecutive numbers is less than 0.
If yes, then append the elements in the list.
I have a series of lists with 7 elements (but could be any number). I am trying to find the lists that have all positive elements, all negative elements, and those that change sign at ANY point,
for example [3, 6, 7, -2, -5, -1, -1] or [3, 1, -1, -2, -1, -5, -1].
Note that, though I used integers in my example, the lists are actually made of floats.
I can easily find all lists that are always positive or negative, but how do I find those that change sign (it could go from positive to negative as in example or from negative to positive).
Find sequences where all elements have same sign and then change sign