Created
May 15, 2012 16:12
-
-
Save Geekfish/2702957 to your computer and use it in GitHub Desktop.
Split a string every x characters
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 split_per_x_chars(m, step): | |
return [m[x:x+step] for x in range(0, len(m), step)] | |
split_per_x_chars('abcdefghijklmnop', 3) | |
# ['abc', 'def', 'ghi', 'jkl', 'mno', 'p'] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
indeed, thanks