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 Cleaner Code Through Refactoring

missing error requirement

just fyi, one error that is missing from this is if the users selects 0 tickets.

The price comes back as "2" which is 0 * 10 + 2.

There should be an additional error raised if the user tries to purchase 0 tickets.

        ticket_quantity = int(ticket_quantity)
        if ticket_quantity > tickets_remaining:
            raise ValueError("There are only {} tickets remaining.".format(tickets_remaining))
        if ticket_quantity < 1:
            raise ValueError("You must select at least one(1) ticket.")```

1 Answer

Steven Parker
Steven Parker
231,275 Points

Good enhancement! But please edit your code and add Markdown formatting to preserve the code's appearance (particularly indentation).

Craig might have left this intentionally for sharp-eyed developers to further practice their skills. Even if not, you'll find that many of the example programs in the courses can benefit from well-conceived enhancements.