Write a python function to convert iterable to pairwise iterable


Topic: Write a python function to convert iterable to pairwise iterable

Solution

def pairwise(iterable):
    from itertools import tee
    a, b = tee(iterable)
    next(b, None)
    return zip(a, b)



List all Python Programs