Skip to content

Instantly share code, notes, and snippets.

@drmingle
Created May 4, 2018 12:46
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save drmingle/01039d4831e6612864cad277ba59ca93 to your computer and use it in GitHub Desktop.
Save drmingle/01039d4831e6612864cad277ba59ca93 to your computer and use it in GitHub Desktop.
title author date
Add Padding Around String
Damian Mingle
05/04/2018

Generate Text

text = 'Data Science is important stuff!'

Add Padding Around Text

# Add Padding on Left
format(text, '>50')
'                  Data Science is important stuff!'
# Add Padding on Right
format(text, '<50')
'Data Science is important stuff!                  '
# Add Padding for Both Right and Left
format(text, '^50')
'         Data Science is important stuff!         '
# Add '#' as Padding on Each Side
format(text, '#^50')
'#########Data Science is important stuff!#########'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment