I have the following list of tuples:
a = [(1, 2), (2, 4), (3, 1), (4, 4), (5, 2), (6, 8), (7, -1)]
I would like to select elements whose second value in the tuple increases compared to the previous one. For example, I would choose (2, 4)because it is 4superior 2, in the same way I would choose (4, 4)and (6, 8).
Can this be done in a more elegant way than a loop that starts explicitly with the second element?
To clarify, I want to select tuples for which the second element exceeds the second element of the previous tuple.
source
share