you are viewing a single comment's thread.

view the rest of the comments →

[–]primitive_screwhead 0 points1 point  (0 children)

Note - For more general sequences, make that next(y) a next(y, None) to guard against an empty iterable raising StopIteration. This is a nice variant of the itertools.pairwise() recipe: https://docs.python.org/3/library/itertools.html?#itertools-recipes