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.

Perfect Storm
1,416 PointsWhy doesn't my service charge work?
Hi everyone!
Everything has been running smoothly until I've had to add the service charge. For some reason it just ignores it. (Don't worry, I've checked to see if my work was saved.) Where am I going wrong?
SERVICE_CHARGE = 2
TICKET_PRICE = 10
tickets_remaining = 100
def calculate_price(number_of_tickets):
return (number_of_tickets * TICKET_PRICE) + SERVICE_CHARGE
while tickets_remaining >= 1:
print("There are currently {} tickets available.".format(tickets_remaining))
name = input("Hello, what is your name? ")
num_tickets = input("Hey {}, how many tickets would you like? ".format(name))
num_tickets = int(num_tickets)
calculation = TICKET_PRICE * num_tickets
print("Great, {} tickets will cost you".format(num_tickets), calculation, "pounds.")
proceed = input("Would you like to proceed?\nEnter Yes or No: ")
if proceed.lower() == 'yes':
# TODO: Gather credit card information and process it.
print("SOLD!")
tickets_remaining -= num_tickets
else:
print("Thanks for your time {}".format(name))
print("I'm afriad the tickets have now sold out.")
1 Answer

Tyler B
5,775 PointsYou're not actually calling your function to calculate price see line 14
calculation = TICKET_PRICE * num_tickets
should be
calculation = calculate_price(num_tickets)
Perfect Storm
1,416 PointsPerfect Storm
1,416 PointsTyler, you're a genius. Thank you, I've been staring at it for over an hour now.