UPPERCASE_LETTERS = ["A", "B", "C", "D", "E", "F", "G", "H", "I", "J", "K", "L", "M", "N", "O", "P", "Q", "R", "S", "T", "U", "V", "W", "X", "Y", "Z"] LOWERCASE_LETTERS = ["a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "l", "m", "n", "o", "p", "q", "r", "s", "t", "u", "v", "w", "x", "y", "z"] def uppercase(word): out = "" for x in word: if x in LOWERCASE_LETTERS: out += UPPERCASE_LETTERS[LOWERCASE_LETTERS.index(x)] else: out += x return out def convert_list_to_strs(lst): lst_copy = [] for x in lst: lst_copy.append(str(x)) return lst_copy def is_answer(s, yn): return s is not None and len(s) > 0 and uppercase(s[0]) in yn def prompt_yes_no(prompt): result = None while not is_answer(result, set(["Y", "N"])): result = input(prompt) return is_answer(result, set(["Y"])) def ask_for_choice(prompt, valid_choices): choices = convert_list_to_strs(valid_choices) choice = None while not choice: proposed = input(prompt) if proposed in choices: choice = proposed else: print("That's not a valid choice! Try one of: " + ", ".join(choices) + ".") return proposed