def read_number(dtype, prompt='', floor=None, ceil=None, repeat=False):
    """ Reads a number within specified bounds. """
    
    while True:
    
        try:
            result = dtype(input(prompt))
            if floor is not None and result < floor:
                raise ValueError(f'Number must be no less than {floor}.')
            if ceil is not None and result > ceil:
                raise ValueError(f'Number must be no greater than {ceil}.')
        except ValueError as e:
            print(e)
            result = None
            
        if result is not None or not repeat:
            return result