title: How to print currency symbol and an n-digit decimal number right aligned in Python
body: <p>I'm making an EMI calculator, which displays an amortization table after displaying monthly EMI.</p>
  
  <p>How can I right align the currency symbol and any n-digit decimal number?</p>
  
  <p>I tried to right align currency symbol and amount by using <code>'{0}{1:5.2f}'.format(rupee, amount)</code> but it didn't solve the problem stating incorrect format string.</p>
  
  <p>The amounts are floating point numbers with more than 2 decimal places, they need to rounded off upto 2 decimal places.</p>
  
  <p>Here's the code which displays 4 amount values (I'm using INR as the currency symbol) :</p>
  
  <pre><code>rupee = chr(8377)
  print('{0}{1:.2f}'.format(rupee, amount1))
  print('{0}{1:.2f}'.format(rupee, amount2))
  print('{0}{1:.2f}'.format(rupee, amount3))
  print('{0}{1:.2f}'.format(rupee, amount4))
  </code></pre>
  
  <p>Some edits need to be made in this sample code to right align the currency symbol and amount, but I'm not able to figure that out.</p>
  
  <p>Actual Output:</p>
  
  <pre><code>$1.07
  $22.34
  $213.08
  $4.98
  </code></pre>
  
  <p>Expected Output:</p>
  
  <pre><code>  $1.07
   $22.34
  $213.08
    $4.98
  </code></pre>
  
  <p>Taking <code>$</code> symbol as the currency symbol because the rupee symbol can't be typed directly from the keyboard.</p>