-
-
Save dotpot/266ec6431e565e15d77f to your computer and use it in GitHub Desktop.
This file contains hidden or 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 space(s, n): | |
"""inserts a space every n characters in string s | |
>>> space('0123456789', 3) | |
'012 345 678 9' | |
>>> space('0123456789', 4) | |
'0123 4567 89' | |
""" | |
return ' '.join(s[i:i+n] for i in range(0, len(s), n)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment