for x in i:
    if o and o[-1] and x - step == o[-1][-1]:
        o[-1].append(x)
else:
    o.append([x])
return o
_get_parts([0, 1, 3, 5, 6, 7], step=1)
Python: split list of integers based on step between them