def to_ranges(lst):
    for a, b in itertools.groupby(enumerate(lst), lambda t: t[1] - t[0]):
        b = list(b)
        yield b[0][1], b[-1][1]
Converts a list of numbers to a list of ranges::
dataset/ETHPy150Open kmike/port-for/port_for/utils.py/to_ranges