from itertools import groupby
from operator import itemgetter
data = [1, 4, 5, 6, 10, 15, 16, 17, 18, 22, 25, 26, 27, 28]
for k, g in groupby(enumerate(data), lambda i_x: i_x[0] - i_x[1]):
    pass
Обнаружение последовательных целых чисел в списке