def take_input(input_type, options) -> int: if input_type not in Constants.input_types: Print.bold_string('Wrong input type: {0}'.format(input_type)) exit(1) specific_text = Constants.specific_text[input_type] no_of_options = len(options) Print.bold_string(specific_text) for i in range(1, len(options)): Print.option(i, options[i]) index = Helper.take_int_input(no_of_options) return options[index]
def take_input(input_type, options): if input_type not in Constants.input_types: Print.bold_string('Wrong input type: {0}'.format(input_type)) exit(1) specific_text = Constants.specific_text[input_type] no_of_options = len(options) Print.bold_string(specific_text) for i in range(1, len(options)): Print.option(i, options[i]) while True: index = int(input()) if 1 <= index <= no_of_options: break else: Print.wrong_option() continue return options[index - 1]