Created
August 25, 2016 11:34
-
-
Save KingCprey/784f88f720659fd082da4872c29a3133 to your computer and use it in GitHub Desktop.
Split iterable every nth value
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
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