Say we have a list L = [1,2,3,4,5]
. Is there a clean way to make a list of tuples of the following form: T = [(1,2),(2,3),(3,4),(4,5)]
?
It would be great if there were a nicer alternative to
T = []
for i in range(len(L) - 1):
T.append((L[i], L[i+1]))
Or the equivalent comprehension.