''' CSCI 204 exercise on user defined exceptions This application raises a user-defined exception when the value of the input is outside the specifications. ''' from limit_range_exceptions import ValueOutRangeException n = 0 lo_limit = 0 hi_limit = 10 while True: try: n = int(input('Type a number : ')) if n >= lo_limit and n <= hi_limit: # good break else: # raise value out of range exception raise ValueOutRangeException except ValueOutRangeException as ex: print('Try again ...' + ' Exception type : ' + type(ex).__name__) print('Exception name : ' + str(ex)) print('You entered a value : ' + str(n))