def prompt_bool(prompt, default=False):
    """
    Prompt user for a yes or no answer and return the result as a boolean.

    :param str prompt: Prompt. ``' [y/n] '`` will be appended to this value
    :param bool default: Default value if user enters nothing
    :return: Boolean indicating user's choice
    :rtype: :class:`bool`
    """
    if default is True:
        choices = ' [Y/n] '
        flip_if = 'n'
    else:
        choices = ' [y/N] '
        flip_if = 'y'
    response = input(prompt + choices)
    if response and response[0].lower() == flip_if:
        return not default
    return default
