Fill in the missing word in this program. class TooWide(Exception): pass answer = input(‘How wide is it? ‘) width = float(answer)

Fill in the missing word in this program. class TooWide(Exception): pass answer = input('How wide is it? ') width = float(answer) try: if width > 30: raise TooWide else: print("Have a nice trip!") TooWide: print("Your luggage will not fit in the overhead bin.")

Related Posts

This Post Has 3 Comments

  1. Replace with except

    Explanation:

    Your program is an illustration to try except in Python

    When the Python interpreter sees a try statement, it expects a corresponding an except statement

    So, the complete program is:

    class TooWide(Exception): pass

    answer = input('How wide is it? ')

    width = float(answer)

    try:

         if width > 30:

               raise TooWide

         else:

               print("Have a nice trip!")

    except TooWide:

         print("Your luggage will not fit in the overhead bin.")

Leave a Reply

Your email address will not be published. Required fields are marked *