iterate through list like in sliding window
python
Solution
l = [1, 2, 3, 4, 5, 6]
for i in range(len(l)):
print l[i : i+3]
Output
[1, 2, 3]
[2, 3, 4]
[3, 4, 5]
[4, 5, 6]
[5, 6]
[6]
Problem
How can I implement this kind of iteration similar to sliding window method in python. ``` Given s = [1, 2, 3, 4, 5, 6] [1, 2, 3] [2, 3, 4] [3, 4, 5] [4, 5, 6] [5, 6] [6] ```