Add Padding Around String

Want to learn more? I recommend these Python books: Python for Data Analysis, Python Data Science Handbook, and Introduction to Machine Learning with Python.

Create Some Text

text = 'Chapter 1'

Add Padding Around Text

# Add Spaces Of Padding To The Left
format(text, '>20')
'           Chapter 1'
# Add Spaces Of Padding To The Right
format(text, '<20')
'Chapter 1           '
# Add Spaces Of Padding On Each Side
format(text, '^20')
'     Chapter 1      '
# Add * Of Padding On Each Side
format(text, '*^20')
'*****Chapter 1******'