def ask(question: str, default=None):
    """
    If "default" is None, prompts the user with "question" for a "yes" or "no"
    answer and returns a boolean.  Otherwise prompts the user to enter a string
    which will be converted to the type of "default".  If the user enters an
    empty string then return "default".
    :param question: Question to ask user.
    :type question: str
    :param default: Default object to return if this is not a true/false question.
    :type default: Object
    :return: Either true or false, or an object of type "default".
    :rtype: bool or Object
    """
    if default is None:
        while True:
            answer = input(question + " ").lower().lstrip()
            if len(answer) == 0 or answer[0] == "y":
                return True
            elif answer[0] == "n":
                return False
            else:
                print('Please enter "yes" or "no".')
                print('Just pressing <Enter> is assumed to mean "yes".')
    else:
        new_question = f"{question} (default={str(default)}) "
        answer = input(new_question)
        if len(answer) == 0:  # If the user pressed <Enter> then
            return default  # return default, else convert answer
        else:  # (which is a str) to default's type.
            return type(default)(answer)