utive_groups(iterable): ... print(list(group)) [1] [10, 11, 12] [20] [30, 31, 32, 33] [40] To find runs of adjacent letters, apply :func:`ord` function to convert letters to ordinals. >>> iterable = 'abcdfgilmnop' >>> ordering = ord >>> for group in consecutive_groups(iterable, ordering): ... print(list(group)) ['a', 'b', 'c', 'd'] ['f', 'g'] ['i'] ['l', 'm', 'n', 'o', 'p'] Each group of consecutive items is an iterator that shares it source with *iterable*. When an an output group is advanced, the previous group is no longer available unless its elements are copied (e.g., into a ``list``). >>> iterable = [1, 2, 11, 12, 21, 22] >>> saved_groups = [] >>> for group in consecutive_groups(iterable): ... saved_groups.append(list(group)) # Copy group elements >>> saved_groups [[1, 2], [11, 12], [21, 22]] Nc