Now, add another condition to your existing if statement using the or operator to check if is_member is truthy. Use the parentheses () to group the show_time != ‘Evening’ and is_member conditions together as shown in the above example.
Your code so far
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 is_weekend or show_time == 'Evening':
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')
# User Editable Region
# User Editable Region
else:
print('Ticket booking failed due to restrictions')
Your browser information:
User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/144.0.0.0 Safari/537.36 Edg/144.0.0.0
Now you will calculate service charges based on the type of seat the user has selected.
Still inside your last if statement body, create a variable named service_charges and set it to 0.
Then, create a nested if statement to check if seat_type is equal to Premium. Inside the body of the if statement, update the service_charges value to 5
I can’t seem to find the error or issue that his holding me down in this task
This is the question: Now you will calculate service charges based on the type of seat the user has selected.
Still inside your last if statement body, create a variable named service_charges and set it to 0.
Then, create a nested if statement to check if seat_type is equal to Premium. Inside the body of the if statement, update the service_charges value to 5.
This was my answer:
sevice_charges = 0
if seat_type == 'Premium':
service_charges = 5
I’ve edited your post to improve the readability of the code. When you enter a code block into a forum post, please precede it with three backticks to make it easier to read.
You can also use the “preformatted text” tool in the editor (</>) to add the backticks.
Hey had the same issue as you. Looked ahead to step 21 and copied the code. Now I am just reverse engineering it so I can understand. …. will probably be stuck on step 21 now.
Probably, yeah. Just getting the answer like that isn’t really how the course is designed to learn.
It is great that you solved the challenge, but instead of posting your full working solution, it is best to stay focused on answering the original poster’s question(s) and help guide them with hints and suggestions to solve their own issues with the challenge. How to Help Someone with Their Code Using the Socratic Method
We are trying to cut back on the number of spoiler solutions found on the forum and instead focus on helping other campers with their questions and definitely not posting full working solutions.
Didn’t know I couldnt post code… I literally got it off another page in forum…. (step 18 has poorly written explanation/steps) . Course would be better if there was more help in the actual steps. j/s
sure don’t get me wrong. I appreciate all the resources giuthub and freecodecamp has; just at times I feel it may be written that the reader has some assumed idea (mainly how to structure the code). I think Step 18 needs to have a better emphasis on the proper intention and how to group the code.
this is a really new workshop, we appreciate all feedback, if you are able to pinpoint what infos or explanation are missing that would really help in improving it
If you have a question about a specific challenge as it relates to your written code for that challenge and need some help, click the Help button located on the challenge.
The Help button will create a new topic with all code you have written and include a link to the challenge also. You will still be able to ask any questions in the post before submitting it to the forum.
I have same problem, getting stuck in step 18 with error declare var service_charges. So the solution is when you want to indent the code, use spacebar instead tab (im using phone and don’t know if it work in pc).
If you have a question about a specific challenge as it relates to your written code for that challenge and need some help, click the Help button located on the challenge.
The Help button will create a new topic with all code you have written and include a link to the challenge also. You will still be able to ask any questions in the post before submitting it to the forum.