Question: This is the error I'm getting for this problem: File C:UsersUserOneDriveDesktopFFinalProject.py, line 103, in determining hours credits = int(fields[1]) IndexError: list index out of

This is the error I'm getting for this problem:

 File "C:\Users\User\OneDrive\Desktop\F\FinalProject.py", line 103, in determining hours
   credits = int(fields[1])
IndexError: list index out of range

StudyHours Notepad File Edit Format View Help philip Rivers apple Joe Theismann 

def determine hours():
      with open ("StudyHours.txt", "r") as file1:
             data = file1.readlines()
             total_study_hours = 0

      for i, line in enumerate(data):
             if "error" in line:
                    print(f"Error found in line {i + 1}: {line}")
                    correct = input("Do you want to correct this line?(y)")
                    if correct == "y":
                           new_line = input("Enter corrected line:")
                           data[i]=new_line
      for record in data:    
             fields = record.strip().split(',')
             print(fields)
             name = fields[0].title()
             credits = int(fields[1])
             grade = fields[2]

StudyHours Notepad File Edit Format View Help philip Rivers apple Joe Theismann 15 B Aaron RODgers 12 A Tom brady 9 K JULIO JONES 50 P but's tyREEK hill 12 C MIKE gisecki 21 A DREW brees 12 B AJ Mccarron 15 Mac JONES 9 A

Step by Step Solution

3.46 Rating (159 Votes )

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock

The error message IndexError list index out of range indicates that you are trying to access an inde... View full answer

blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!