Skip to content

Instantly share code, notes, and snippets.

@KingCprey
Created August 25, 2016 11:34
Show Gist options
  • Save KingCprey/784f88f720659fd082da4872c29a3133 to your computer and use it in GitHub Desktop.
Save KingCprey/784f88f720659fd082da4872c29a3133 to your computer and use it in GitHub Desktop.
Split iterable every nth value
def yieldByN(tosplit,n):
for s in range(0,len(tosplit),n):
yield tosplit[s:s+n]
def splitByN(tosplit,n):return [v for v in yieldByN(tosplit,n)]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment