Just
zip(seq, seq[1:])
Won't work with iterator though. zip(seq, seq[1:])
Won't work with iterator though. all(a < b for a,b in zip(seq,seq[1:]))
(Although one might want <= if checking to see if the sequence is sorted, rather than strictly ascending (that is, it can contain matching/repeated elements)). def pairwise(iterable):
"s -> (s0,s1), (s1,s2), (s2, s3), ..."
a, b = tee(iterable)
next(b, None)
return izip(a, b)
https://docs.python.org/2/library/itertools.html#itertools.i...