This is my code. In the first def function, I made it return column_choose, and I wanna use column_choose's value in second def function(get_data_list). What can I do? I have tried many times. But IDLE always show:global name 'column_choose' is not defined.
How to use column_choose's value in second function? By the way, I use python 3.2
def get_column_number():
while True:
column_choose = input('What column:')
if column_choose == '1' or column_choose == '2' or column_choose == '3' or column_choose == '4' or column_choose == '5' or column_choose == '6':
column_choose = int(column_choose)
return column_choose
break
else:
print('bad column number, try again')
def get_data_list(column_number):
new_column_number = column_number.split(',')
date_column = new_column_number[0]
choose_column = new_column_number[column_choose-1]
return result
def main():
#Call get_input_descriptor
get_input_descriptor()
#Call get_column_number
get_column_number()
file_obj = open("table.csv", "r")
for column_number in file_obj:
column_number = (column_number.strip())
result = get_data_list(column_number)
print(result)
file_obj.close()
main()