I am attempting to index a list to pull the first (0) and second (1) items for further calculations. My code currently looks like this:
def calculate_scores(list):
sat = list[0]
gpa = list[1]
weighted_sat = (sat / 160)
weighted_gpa = (gpa * 2)
This is in the function that I want to use to do the calculations. The part where this function is called in my main looks like this:
testscores = []
semestergrades = []
testscores.append(floatlist[0:4])
semestergrades.append(floatlist[4:])
calculate_scores(testscores)
The list that the testscores list is pulling from is 8 items long, all of them floats - however, when I try to run this code it gives me a 'list index out of range' error for the part where I try to set the variable 'gpa' equal to list[1]. However, it seems to be able to run the first part, setting the variable 'sat' equal to list[0]. Any idea why this is happening?