v Add Padding Around String - Python

Add Padding Around String

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******'