This is the error I'm getting for this problem: File C:UsersUserOneDriveDesktopFFinalProject.py, line 103, in determining hours
Question:
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
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]
Income Tax Fundamentals 2013
ISBN: 9781285586618
31st Edition
Authors: Gerald E. Whittenburg, Martha Altus Buller, Steven L Gill