Skip to content

Instantly share code, notes, and snippets.

@eserge
Last active September 9, 2020 16:09
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save eserge/76f7d6de72a147ff4b0049b0975b56d1 to your computer and use it in GitHub Desktop.
Save eserge/76f7d6de72a147ff4b0049b0975b56d1 to your computer and use it in GitHub Desktop.
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