I would use it itertools, but if you find it difficult (as you hinted at at the comment), then it’s possible:
def twobytwo(t):
it = iter(t)
for x in it:
yield x, next(it)
d = dict(twobytwo(t))
or equivalent, and return to itertools again,
def twobytwo(t):
a, b = itertools.tee(iter(t))
next(b)
return itertools.izip(a, b)
d = dict(twobytwo(t))
or, if you insist on being inbuilt, in a suitable “trick or treat” mood season:
d = dict((x, next(it)) for it in (iter(t),) for x in it)
, , , . IOW, , , , : -).
, , " 2 ", dict 2- . , , O(1) ( , O(N), dict, ).
docs ( , itertool) - pairwise on , , . , - iterutils.py (, python stdlib!).