def pairwise(iterable):
    iterator = iter(iterable)
    try:
        a = iterator.next()
    except StopIteration:
        return
    for b in iterator:
        yield a, b
        a = b
Yield pairs of consecutive elements in iterable.
dataset/ETHPy150Open SimonSapin/snippets/markov_passwords.py/pairwise