A Pythonic way to access a list pairwise is: zip(L, L[1:])
. To connect the last item to the first one:
>>> L = [1, 2, 3]
>>> zip(L, L[1:] + L[:1])
[(1, 2), (2, 3), (3, 1)]
A Pythonic way to access a list pairwise is: zip(L, L[1:])
. To connect the last item to the first one:
>>> L = [1, 2, 3]
>>> zip(L, L[1:] + L[:1])
[(1, 2), (2, 3), (3, 1)]