I have a list such as [6,6,2,6,6,7,5,2,0,5,6].
I can enumerate it to get the list [(0,6),(1,6),(2,2),(3,6),(4,6),(5,7),(6,5),(7,2),(8,0),(9,5),(10,6)] very easily.
Then, what I want is to save the values of every index which has a 2nd value >= 5; that is, the output of that would be [0, 1, 3, 4, 5, 6, 9, 10].
I can do this very well so far. Now, what I desire is to parse this in this fashion:
[(0,1),(3,4,5,6),(9,10)]
Separating the items into groups where the difference between any two adjacent items is exactly 1.
My code so far:
histo = [6,6,2,6,6,7,5,2,0,5,6]
histo = list(enumerate(histo))
abarrote = [x[0] for x in histo if x[1] >= 5]
#Out[1]: [0, 1, 3, 4, 5, 6, 9, 10]
#Desired output: [(0,1),(3,4,5,6),(9,10)]
Thanks in advance.