Iteration Classes

itertools.pairwise()

Emit overlapping successive pairs, producing one fewer pair than input items.

Formal Syntax & Structure

python syntaxpython
itertools.pairwise(iterable, /)

Parameters & Attributes

NameTypeDescription
iterableiterableInput values, consumed as needed.

Return Value

iterator

The iterator result described above.

Working Example

Example Snippetpython
import itertoolsprint(list(itertools.pairwise([4,7,9])))
Python Reference