Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

Python Python Basics All Together Now Branch and Loop

Dolapo Sekoni
PLUS
Dolapo Sekoni
Courses Plus Student 1,431 Points

stucked at the last code

hello all,

kindly help detect what the error might be, i decided to do this on my own without the video and though everything seems fine i keep getting syntax error at the last code "print("sorry all the tickets are sold out").

kindly help check.

link below .. file name is masterticket2.py

https://w.trhou.se/j9se1g17wh

thanks

2 Answers

Alex Koumparos
seal-mask
.a{fill-rule:evenodd;}techdegree
Alex Koumparos
Python Development Techdegree Student 36,887 Points

Hi Dolapo,

I ran your code and noticed three bugs.

The first error is the syntax error you mentioned. Sometimes you'll look at a stack trace like the one you were getting and think, "there's nothing wrong with this line of code". When you get this situation, it's often the case that the previous line is missing something that will end that line of code, so Python is treating your last line of code as if it was a continuation of the previous expression.

This is the problem you have here. Look at the previous line:

print("Thanks anyways {}".format(name)

You'll notice that you are missing a closing parenthesis. This is causing Python to treat your final line as part of this print statement.

Once you fix this, you'll notice the next error, which occurs when choosing the number of tickets:

    number_tickets = input("How many tickets would you like,{}? ".format(name))
    number_tickets = int(num_tickets)

In the second line above, you are referring to num_tickets but your variable is number_tickets.

Then you have another error if you attempt to buy more tickets than available:

raise ValueError("There are only {} tickets available".format(tickets_remaing))

This is because you have a typo in tickets_remaing

Hope that helps

Alex