def confirm(prompt=None, resp=False):
    """
        Source: http://code.activestate.com/recipes/541096-prompt-the-user-for-confirmation/
        prompts for yes or no response from the user. Returns True for yes and
        False for no.
        'resp' should be set to the default value assumed by the caller when
        user simply types ENTER.
        >>> confirm(prompt='Create Directory?', resp=True)
        Create Directory? [y]|n:
        True
    """

    if prompt is None:
        prompt = 'Confirm'

    if resp:
        prompt = '%s [Y/n]: ' % (prompt)
    else:
        prompt = '%s [y/N]: ' % (prompt)

    while True:
        ans = input(prompt)
        if not ans:
            return resp
        if ans not in ['y', 'Y', 'n', 'N']:
            print('please enter y or n.')
            continue
        if ans == 'y' or ans == 'Y':
            return True
        if ans == 'n' or ans == 'N':
            return False