def limit(lst, index, offset=None, step=1):
    """Constrain the number of items.
    """
    if offset is None:
        offset = len(lst)
    else:
        offset = offset + index
    return lst[index:offset:step]