EDIT: Got it working now, Thanks. It was an empty line on the Text file as someone commented
Beginner here - I'm getting an error saying list index out of range, but I'm referencing a position in the list that should be in range. The error is on the line "courseGPA = GPAconverter(line[2])" which calls my function, GPAconverter.
Im trying to create a program that reads each line of a text file containing a course, the weight of that course, and the grade of that course. I want it to read the course grade, put it through a function i've created, and convert it to a GPA. Then eventually I want the code to output my final GPA.
The format of the txt file is:
Math, 0.5, 80
for line in inputFile:
line = line.rstrip()
line = line.split(",")
courseGPA = GPAconverter(line[2])
if float(line[1]) == 0.5:
count = count + 1
totalGPA += courseGPA
elif float(line[1]) == 1.0:
count = count + 2
totalGPA += 2*(courseGPA)
elif float(line[1]) == 2.0:
count += 4
totalGPA += 4*(courseGPA)
else:
print("Somethings wrong")