def incremental_window(it):
    """Produce monotonically increasing windows on an iterable.
    Only complete windows are yielded, if the last elements do not form
    a complete window they are ignored.
    incremental_window('ABCDEF') -> ['A'], ['B', 'C'], ['D', 'E', 'F']
    incremental_window('ABCDE') -> ['A'], ['B', 'C']
    """
it = iter(it)
return ([next(it) for _ in _range(s)] for s in count(1))
Элементы группировки Python в списке по возрастанию