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

MY SOLUTION

TICKET_PRICE = 10

tickets_remaining = 100

Output the number of tickets remaining using the tickets remaining variable

print("The number of tickets remaining is {}".format(tickets_remaining))

Gather the user 's name and assign it to a new variable

user_name = input("May you please enter your name: ")

Prompt the user by name and ask them how many tickets they would like

num_of_tickets = int(input("{} How many tickets would you like to order : ".format(user_name.capitalize())))

Calculate the price (number of tickets multiplied by the price) and assign it to a variable total

total_cost = num_of_tickets*TICKET_PRICE

Output the price to the screen

print("{}, the total cost of the tickets you would like to order is ${}".format(user_name,total_cost))

1 Answer

Ams BM
Ams BM
5,898 Points

Nice, mines is quite similar but I like using the f string method, rather than the .format method

TICKET_PRICE = 10
ticket_remaining = 100

print(f"There's {ticket_remaining} tickets remaining.")

users_name = input("Please enter your name: ")

num_of_tickets = int(input(f"Hi {users_name}, how many tickets would you like? "))

ticket_price_cal = num_of_tickets * TICKET_PRICE

print(f"That's {num_of_tickets} tickets, total cost is ${ticket_price_cal}")