Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
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
You can’t perform that action at this time.