Other answers used several functions from itertools:
We can check out the docs (remember)
To get the elements in groups of two (advancing one index at a time):
Or, you can do a full itertools solution with the functions tee and izip as well as cycle.
tee
makes two independent iterators for the sequence and izip
zips them up (of course):Or use
islice
: