# Functions go here from asyncore import loop from typing import Tuple # Functions go here def string_check(question, valid_ans_list=('exit', 'different order'), num_letters=1): """Checks that users enter the full word or the 'n' letter/s of a word from a list of valid responses :rtype: object""" while True: response = input(question).lower() for item in valid_ans_list: # check if the response is the entire world if response == item: return item # check if it's the 'n' letters elif response == item[:num_letters]: return item print(f"Please choose an option from {valid_ans_list}") # Main routine goes here purchase_ans: tuple[str, str] = ('confirm', 'cancel') # purchase_method = string_check("Do you want to confirm purchase or cancel? ", purchase_ans, 2) # print(f"You chose to {purchase_method}") while True: purchase_method = string_check("Do you want to confirm purchase or cancel? ", purchase_ans, 2) print(f"Your order has been {purchase_method}") print() break final_ans = string_check("Do you want to make a different order or exit the program?") while True: print() # ask user if they want to exit or make another order (and check it's not blank) exit_different_order = final_ans if exit_different_order == "exit": break if exit_different_order != "different order": def loop(repeat):