Generate consecutive pairs of elements from the given iterable.

def pairwise(iterable):
    """
    Generate consecutive pairs of elements from the given iterable.
    """
    iterator = iter(iterable)
    try:
        first = next(iterator)
    except StopIteration:
        return
    for element in iterator:
        yield first, element
        first = element