Last active
September 9, 2020 16:09
-
-
Save eserge/76f7d6de72a147ff4b0049b0975b56d1 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from itertools import islice, tee | |
def cut_chunks(iterable, size): | |
it = iter(iterable) | |
while True: | |
test_chunk, chunk = tee(islice(it, size)) | |
try: | |
next(test_chunk) | |
yield chunk | |
except StopIteration: | |
return | |
i = range(1, 93) | |
for chunk in cut_chunks(i, 10): | |
print(list(chunk)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment