Follow a failure through a caller

A theatre calculates remaining seats with the following Python functions. All quantities are integer seat counts, and neither function handles exceptions.


Python
def reserve(requested, available):
    if requested > available:
        raise ValueError("requested exceeds available")
    return available - requested

def reserve_two(available):
    remaining = reserve(8, available)
    return reserve(5, remaining)


What happens when reserve_two(12) is evaluated?

Choose an answer

Create a free account to get started

Unlock full course notes by signing up

  • Video lessons taught by top educators
  • Practice questions with guided solutions
  • Written review notes for reference
  • Expert answers anytime from course tutors

More Raising Exceptions Questions: