Skip to content

Instantly share code, notes, and snippets.

@kissgyorgy
Created June 8, 2016 20:36
Show Gist options
  • Save kissgyorgy/edc7204bbf549b62445921448337511e to your computer and use it in GitHub Desktop.
Save kissgyorgy/edc7204bbf549b62445921448337511e to your computer and use it in GitHub Desktop.
Python: leftpad without stdlib
def leftpad(string, length):
if len(string) >= length:
return string
spaces_to_add = length - len(string)
return ' ' * spaces_to_add + string
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment