Invalid format specifier for thousands place
<p>I am trying to make a simple chart like output. Here are strings that I want to display:</p>

<p>a = "name", b = "10000.00", c = "code", d = "45.60", e = "30.00"</p>

<pre><code>print("{0:20}${1:,20}{2:20}${3:,20}${4:,&lt;5}".format(a,b,c,d,e),file=outfile)
</code></pre>

<p>I put "," to indicate thousands place in each format specifier in which I want them to be output as currency. It reports the error:</p>

<pre><code>print("{0:20}${1:,20}{2:20}${3:20}${4:&lt;5}".format(a,b,c,d,e),file=outfile)
ValueError: Invalid format specifier
</code></pre>

<p>What did I do wrong?</p>

<p>As per the <a href="https://docs.python.org/3/library/string.html#format-specification-mini-language" rel="nofollow">docs</a>, width has to go after comma. Moreover, your <code>b</code> variable has to be a number (and not a string, as in your MWE):</p>

<pre><code>&gt;&gt;&gt; x = 10000.0
&gt;&gt;&gt; '{0:20,}'.format(x)
'            10,000.0'
</code></pre>

python