I am working on a function that is generating a list of indexes based on a provided string. For instance [0, 1, 3, 4, 5, 6, 7, 14, 15, 16, 17, 19, 20, 26]. If the list contains at least five consecutive indexes, a new list should be created containing such indexes. For example, from the above list, the list [3, 4, 5, 6, 7] should be created.
flags = [0, 1, 3, 4, 5, 6, 7, 14, 15, 16, 17, 19, 20, 26]
IDs = []
count1 = 0
for i in range (len(flags)-1):
if flags[i+1]-flags[i] == 1:
IDs.append(i)
count1 += 1
else:
count1 -= 1
count1 is 5, so IDs should also have five items.