(prompt="Are you sure? ", default=True)
Display a prompt asking for confirmation from the user before continuing; accepts any form of "yes"/"no"

    :param prompt: the prompt to display before accepting input
    :param default: the default value if CR pressed with no input
    :returns: True if "yes", False if "no"
Display a prompt asking for confirmation from the user before continuing; accepts any form of "yes"/"no"
Display a prompt asking for confirmation from the user before continuing ; accepts any form of yes / no
def ask_for_confirmation(prompt="Are you sure? ", default=True):
    """ Display a prompt asking for confirmation from the user before continuing; accepts any form of "yes"/"no"

    :param prompt: the prompt to display before accepting input
    :param default: the default value if CR pressed with no input
    :returns: True if "yes", False if "no"
    """
    yes, no = ("Y", "n") if default else ("y", "N")
    prompt += f"[{yes}/{no}] "

    while True:
        ans = input(prompt).lower().strip()
        if not ans:
            return default
        elif not ("yes".startswith(ans) or "no".startswith(ans)):
            print("Please enter yes or no.")
            continue
        else:
            return "yes".startswith(ans)
def ask_for_confirmation ( prompt = "Are you sure? " , default = True ) : yes , no = ( "Y" , "n" ) if default else ( "y" , "N" ) prompt += f"[{yes}/{no}] " while True : ans = input ( prompt ) . lower ( ) . strip ( ) if not ans : return default elif not ( "yes" . startswith ( ans ) or "no" . startswith ( ans ) ) : print ( "Please enter yes or no." ) continue else : return "yes" . startswith ( ans )