Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

Python Python Basics All Together Now Gather Information

Vincenzo Reo
Vincenzo Reo
1,373 Points

How could we get the amount due to print as currency? I tried float(), but it didn't work as I intended.

... num_tickets = int(input("Hi {}! How many tickets would you like to purchase? ".format(name)))

total_cost = num_tickets*TICKET_PRICE

checkout_message = "Awesome sauce {}! Your total amount due is below: ".format(name) amount_due = float(total_cost)

print(checkout_message) print(amount_due)

1 Answer

Jason Larson
Jason Larson
7,539 Points

I think this is what you're looking for: This will also add a comma as a thousands separator, if they decide to buy 100 or more tickets. (This is just the last line...)

print("${:,.2f}".format(amount_due))