title: Python: String Formatter Align center
body: <pre><code>print('%24s' % "MyString")     # prints right aligned
  print('%-24s' % "MyString")    # prints left aligned
  </code></pre>
  
  <p>How do I print it in the center? Is there a quick way to do this?</p>
  
  <p>I don't want the text to be in the center of my screen. I want it to be in the center of <em>that</em> 24 spaces. If I have to do it manually, what is the math behind adding the same no. of spaces before and after the text?</p>