Python Python Basics All Together Now Branch and Loop

Jonathan Beard
Jonathan Beard
8,366 Points

While loop correction needed for Python Project

When running the final code for the ticket price project, I believe there is an oversight. In the example given where craig buys 98 tickets, leaving two remaining which are then purchased by Terry, there should be a prompt if the number entered exceeds the remaining balance. As it stands now, if Terry were to enter 3 tickets instead of two, the output would be SOLD! Sorry the tickets are all sold out!.

My thought is a ValueError should be included if the number of tickets requested exceeds the remaining ticket balance.

1 Answer

Pedro Cabral
Pedro Cabral
22,426 Points

You must have missed something, there is a check for that:

         if num_tickets > tickets_remaining:
            raise ValueError...