1
print("The cost of paint based on whole gallons is: $", round(paint_costs,2))
The cost of paint based on whole gallons is: $ XXX.XX

How do I omit the space between the $ and amount so that it reads:

The cost of paint based on whole gallons is: $XXX.XX

Is it import.locale?

2
  • in your case, using string formating is the correct answer: "The cost of paint based on whole gallons is: ${0:.2f}".format(paint_costs). Don't use round to format numbers. Commented Feb 28, 2015 at 13:38
  • If you think the solution has answered your problem, then please mark it as accepted. See meta.stackexchange.com/questions/5234/… Commented Mar 4, 2015 at 19:49

2 Answers 2

1

Add sep="" parameter inside the print function.

print("The cost of paint based on whole gallons is: $", round(paint_costs,2), sep="")
Sign up to request clarification or add additional context in comments.

Comments

1

Use the Py3 feature sep

print("The cost of paint based on whole gallons is: $", round(paint_costs,2),sep = "")

Other ways include

  • print("The cost of paint based on whole gallons is: ${}".format(round(paint_costs,2)))
  • print("The cost of paint based on whole gallons is: $%s"%(round(paint_costs,2)))

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.