There the class label is a float, which can’t be indexed because it is just a number. class_total as you had before should be a list with zeros on line 23, then populated on the for loop in line 24.
Your problem before was that for one of your classes line 27 never happens, i.e. you probably are missing one class in your labels because by the time you arrive to the next for loop one of your class_total elements is 0.
Check your class_total before the last for loop to see what I am saying. Then go backwards inspecting labels and so on and you will quickly find the solution.