base_price = 15
age = 21
seat_type = 'Gold'
show_time = 'Evening'
if age > 17:
print('User is eligible to book a ticket')
if age >= 21:
print('User is eligible for Evening shows')
else:
print('User is not eligible for Evening shows')
is_member = False
is_weekend = False
discount = 0
if is_member and age >= 21:
discount = 3
print('User qualifies for membership discount')
else:
print('User does not qualify for membership discount')
print('Discount:', discount)
extra_charges = 0
if show_time == 'Evening' or is_weekend:
extra_charges = 2
print('Extra charges will be applied')
else:
print('No extra charges will be applied')
print('Extra charges:', extra_charges)
if age >= 21 or age >= 18 and (show_time != 'Evening' or is_member):
print('Ticket booking condition satisfied')
service_charges = 0
if seat_type == 'Premium':
service_charges = 5
elif seat_type == "Gold":
service_charges = 3
else:
service_charges = 1
print('Ticket booking failed due to restrictions')
print('Service charges: ', service_charges)
Lesson URL (copy - paste from your browser’s address bar)
The way that I understand the problem is: After my if, elif, else statement the next Step is printing out print(“Service_charges:”, service_charges") outside of my statement chain.
I also tried using print(f"Service_charges: {service_charges}")
I tried using ‘’ rather than “”
The terminal output looks good, prints out “Service_charges: 3”. Is this a bug in the platform itself or am I just missing something stupid?
I just found the solution after resetting the thing. there is another “else” statement that I thought I put in myself by mistake. It was supposed to be there, in case the Ticket booking failed.
Congratulations on solving the challenge! You should be proud of your achievement…we are! But we are removing your working solution, so it is not available to others who have not yet done the work to get there. Again, congrats!
Tried to run this code but cannot move to the next challenge because the message says: ‘You should print Service charges: followed by the value of service_charges below your if...elif...else statement.’
How did you fix it?
Here’s the code: base_price = 15
age = 21
seat_type = ‘Gold’
show_time = ‘Evening’
if age > 17:
print('User is eligible to book a ticket')
if age >= 21:
print('User is eligible for Evening shows')
else:
print('User is not eligible for Evening shows')
is_member = False
is_weekend = False
discount = 0
if is_member and age >= 21:
discount = 3
print('User qualifies for membership discount')
else:
print('User does not qualify for membership discount')
print(‘Discount:’, discount)
extra_charges = 0
if show_time == ‘Evening’ or is_weekend:
extra_charges = 2
print('Extra charges will be applied')
else:
print('No extra charges will be applied')
print(‘Extra charges:’, extra_charges)
if age >= 21 or age >= 18 and (show_time != ‘Evening’ or is_member):
Please create your own topic when you have specific questions about your own challenge code. Only respond to another thread when you want to provide help to the original poster of the other thread or have follow up questions concerning other replies given to the original poster.
The easiest way to create a topic for help with your own solution is to click the Help button located on each challenge. This will automatically import your code in a readable format and pull in the challenge URL while still allowing you to ask any question about the challenge or your code.