import sys def y_n_question(question_str): yes = {'yes','y', 'ye', ''} no = {'no','n'} while True: sys.stdout.write(question_str + " [Y/n]: ") choice = input().lower() if choice in yes: return True elif choice in no: return False else: sys.stdout.write("\nPlease respond with 'yes' or 'no'\n") continue