Skip to content

Instantly share code, notes, and snippets.

@dotpot
Forked from Paulius-Maruska/temp.py
Last active August 29, 2015 14:23
Show Gist options
  • Save dotpot/266ec6431e565e15d77f to your computer and use it in GitHub Desktop.
Save dotpot/266ec6431e565e15d77f to your computer and use it in GitHub Desktop.
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