Oct-12-2018, 05:31 PM
Hello, i am trying to get the user to enter from a given set of options. For that i am using different functions like this:
def decide_input (element): string_input_list = ['Batch', 'Date', 'Village', 'Case Sheet', 'Name', 'Gender', 'Others'] if element in string_input_list: data = input(element + ': ' ).title() if data == 'Exit': print('Exiting...') starter() if 'cchange' not in data: pass else: data = input(element + ' (Enter number): ' ) if data == 'exit': print('Exiting..') starter() elif 'cchange' not in data: try: data = int(data) except: print ('Please enter a number') decide_input(element) print ('-'*88) return data def check_bounds(element, lower_bound=0, upper_bound=0, options_list=[]): new_element = element options = options_list input_value = decide_input(element) if options_list != []: if input_value in options_list: return input_value else: print ('Please select from the listed options') del input_value check_bounds(element=new_element, options_list=options) return input_value elif input_value.isdigit() and input_value > lower_bound and input_value < upper_bound: return input_value else: print('Kindly enter an input between ' + str(lower_bound) and str(upper_bound)) check_bounds(element, lower_bound, upper_bound) return input_value print('Use the following code:\n A - Ramanathapuram\n B - Thondamanatham \n C - Tuthipet \n D - Piliarkuppam \n E - NSA') data = check_bounds('Village', options_list = ['A', 'B', 'C', 'D', 'E']) print('you have entered ' + data)The loop stops when the user enters a valid option, but it outputs the first entered value. How can i fix that?