How would I write a python code for this using split function? Example of input file (.txt) :
3
Day 1
Option A, 30
Option B, 60
Option C, 90
Day 2
Option A, 16
Option B, 24
Option C, 30
Day 3
Option A, 64
Option B, 49
Option C, 39
This should be the output:
List A = [3] #total options available
List B = [110, 133, 159] #sums of each individual option
List C = [1, 2, 3] #number of days
Option A = 110
Option B = 133
Option C = 159
I tried utilising the split function but I don't get the above output
option_num_list = []
total_list =[]
input_file = open(userfile, "r")
for next_line in input_file:
x = next_line.strip().split(",")
option_number = x[0]
option_num_list.append(option_number)
total = x[-1]
total_list.append(total)
print(sum(total_list))