mirror of
https://github.com/Xevion/exercism.git
synced 2026-01-31 08:24:14 -06:00
'init'
This commit is contained in:
@@ -0,0 +1,5 @@
|
||||
from itertools import takewhile
|
||||
def slices(series, length):
|
||||
if length > len(series) or length <= 0:
|
||||
raise ValueError('[length] parameter cannot be {}.'.format('longer than [series]' if length > len(series) else 'shorter than zero'))
|
||||
return list(takewhile(lambda x : len(x) == length, (series[index:index+length] for index in range(len(series)))))
|
||||
Reference in New Issue
Block a user