title: How would I define a fill character for f-string alignment?
body: <p>I've been messing around with text-alignment, including the string methods, and f-strings. My current goal is to create a table of contents styled output, that looks something like this:</p>
  <pre><code>Introduction....................1
  Python Basics...................5
  Creating Your First Program....12
  Operators and Variables........29
  </code></pre>
  <p>Easily enough, I've been able to format it like:</p>
  <pre><code>Introduction                    1
  Python Basics                   5
  Creating Your First Program    12
  Operators and Variables        29
  </code></pre>
  <p>The code being:</p>
  <pre class="lang-py prettyprint-override"><code>for chapt, page in contents:
    print(f&quot;{chapt:&lt;30}{page:&gt;5}&quot;)
  </code></pre>
  <p>I can't find any resources on the web that describe how to add a fill character and f-strings together. Using the <code>.center</code>, <code>.ljust</code>, <code>.rjust</code> string methods, I have been able to do this, as they take the parameter of width and then an optional fill character.
  On <a href="https://stackoverflow.com/questions/54656033/trying-to-understand-some-f-string-magic-formatting-mini-language-in-f-strings">this post</a>, I thought I found a solution.</p>
  <blockquote>
  <p>The <code>x&lt;y</code> portion signifies to left-align the text with a width of y spaces. For any unused space, pad it with character x.</p>
  </blockquote>
  <p>I tried this method, editing my print statement from <code>print(f&quot;{chapt:&lt;30}{page:&gt;5}&quot;)</code> to <code>print(f&quot;{chapt:'.'&lt;30}{page:'.'&gt;5}&quot;)</code>. Yet this returns an error:</p>
  <pre><code>Traceback (most recent call last):
    File &quot;main.py&quot;, line 40, in &lt;module&gt;
      print(f&quot;{chapt:'.'&lt;30}{page:'.'&gt;5}&quot;)
  ValueError: Invalid format specifier
  </code></pre>
  <p>(Line 40 being the line in my full code.)</p>
  <p>Is there any way to choose a fill character, or would I have to revert to the string methods. I believe there is, but I can not figure out how to use it. Thanks!</p>