def summariseList(lst):
    if len(lst) < 2:
        return lst
    ranges = []
    start = 0
    for i in range(1, len(lst)):
        if (lst[i] - lst[i-1]) > 1:
            if (i-1) == start:
                start = i
                ranges.append(lst[i-1])
            else:
                ranges.append((lst[start], lst[i-1]))
                start = i
    if lst[start] == lst[i]:
        ranges.append(lst[i])
    else:
        ranges.append((lst[start], lst[i]))
    return ranges
Takes a sorted list of numbers, and returns a summary.
dataset/ETHPy150Open cortesi/pry/libpry/utils.py/summariseList