Skip to content

Instantly share code, notes, and snippets.

@lotusirous
Created September 10, 2022 03:14
Show Gist options
  • Save lotusirous/cfcee6645c02f8f9c0154f4262d5c173 to your computer and use it in GitHub Desktop.
Save lotusirous/cfcee6645c02f8f9c0154f4262d5c173 to your computer and use it in GitHub Desktop.
def split_by_n(seq, n):
"""Split a sequence by n elements"""
while seq:
yield seq[:n]
seq = seq[n:]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment