title: String Formatting Dollar Sign In Python
body: <p>So I'm trying to get the dollar sign to appear directly to the left of the digits under the column 'Cost'. I'm having trouble figuring this out and any help is appreciated. </p>
  
  <pre class="lang-py prettyprint-override"><code># Question 5
  
  print("\nQuestion 5.")
  
  # Get amount of each type of ticket to be purchased
  
  adultTickets = input("\nHow many adult tickets you want to order: ")
  
  adultCost = int(adultTickets) * 50.5
  
  childTickets = input("How many children (&gt;=10 years old) tickets: ")
  
  childCost = int(childTickets) * 10.5
  
  youngChildTickets = input("How many children (&lt;10 years old) tickets: ")
  
  # Display ticket info
  
  print ("\n{0:&lt;17} {1:&gt;17} {2:&gt;12}".format("Type", "Number of tickets", 
  "Cost"))
  
  print ("{0:&lt;17} {1:&gt;17}${2:&gt;12.2f}".format("Adult", adultTickets, adultCost))
  
  print ("{0:&lt;17} {1:&gt;17}${2:&gt;12.2f}".format("Children (&gt;=10)", childTickets, 
  childCost))
  
  print ("{0:&lt;17} {1:&gt;17} {2:&gt;12}".format("Children (&lt;10)", youngChildTickets, 
  "free"))
  
  #Calculate total cost and total amount of tickets
  
  totalTickets = (int(adultTickets) + int(childTickets) + 
  int(youngChildTickets))
  
  totalCost = adultCost + childCost
  
  print ("{0:&lt;17} {1:&gt;17}${2:&gt;12.2f}".format("Total", totalTickets, totalCost))
  </code></pre>
  
  <p>I also want the cost column to be formatted right, which for some reason it isn't when I run the program.</p>
  
  <p>(My output):</p>
  
  <p><a href="https://i.stack.imgur.com/F70vI.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/F70vI.png" alt="enter image description here"></a>
  Edit: I also can't format the '$' onto the cost, as I have to keep the 2 decimal places in the formatting</p>