From f117c89ec424fddd4553e713f11405e675a899c9 Mon Sep 17 00:00:00 2001 From: Brosef Date: Tue, 16 Dec 2025 12:19:44 +0000 Subject: [PATCH] Added Y/N prompt --- utils.py | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) create mode 100644 utils.py diff --git a/utils.py b/utils.py new file mode 100644 index 0000000..5915db9 --- /dev/null +++ b/utils.py @@ -0,0 +1,22 @@ +""" +A set of common utilities. +""" + +def inputYN(text: str, default: bool=None): + """ + Prompty the user with a yes/no prompt. + + Args: + text (str): The text displayed to the user. + default (bool): The default answer. + """ + + while True: + i = input(text) + + if i.lower() in ['1', 'y', 'yes']: + return True + if i.lower() in ['0', 'n', 'no']: + return False + if default is not None and i == '': + return default