How can I create iterate group of three from a iterate object? For creating a pair of iteration function I can do something like from itertools import tee
def func(iterate):
i, j = tee(iterate)
next(j, None)
return zip(i, j)
l = [1,2,3,4,5]
for a, b in func(l):
print(a, b)
> 1, 2
> 2, 3
> 3, 4
> 4, 5