from itertools import groupby, count
nums = [1, 2, 3, 4, 8, 10, 11, 12, 17]
[list(g) for k, g in groupby(nums, key=lambda n, c=count(): n - next(c))]
Python - find incremental numbered sequences with a list comprehension