Create a generator that yields sliding windows of a sequence.
Constraints
Example
>>> list(windowed([1, 2, 3, 4], 2))
[[1, 2], [2, 3], [3, 4]]
>>> list(windowed('abcdef', 3))
[['a', 'b', 'c'], ['b', 'c', 'd'], ['c', 'd', 'e'], ['d', 'e', 'f']]
>>> list(windowed([1, 2, 3], 5))
[]
Recent Submissions
No submissions yet — hit Run Tests to try!
Hints