def pairwise(iterable):
    """
    Yield pairs of consecutive elements in iterable.
    
    >>> list(pairwise('abcd'))
    [('a', 'b'), ('b', 'c'), ('c', 'd')]
    """
    iterator = iter(iterable)
    try:
        a = iterator.next()
    except __HOLE__:
        return
    for b in iterator:
        yield a, b
        a = b
dataset/ETHPy150Open SimonSapin/snippets/markov_passwords.py/pairwise