mirror of
https://github.com/maciej3031/comixify.git
synced 2026-03-11 08:54:35 +00:00
7 lines
217 B
Python
7 lines
217 B
Python
|
|
def batch(iterable, n=1):
|
||
|
|
length = len(iterable)
|
||
|
|
for ndx in range(0, length, n):
|
||
|
|
end_index = min(ndx + n, length)
|
||
|
|
n_elemnets = end_index - ndx
|
||
|
|
yield n_elemnets, iterable[ndx:end_index]
|