def determine_grade():        try:#creating this block to handle any exceptions that might occur when trying to convert.               with open("Grades.txt", "r") as file:#open Grades to read data                      with open ("HowManyHours.txt", "a") as writeFile:#append data to HowManyHours                             grade_map = {15:"A",12:"B",9:"C",6:"D",0:"F"}#defining the dictionary                             for line in file:                                    line_list = line.strip().split(",")#splitting lines into a list                                    name = line_list[0].title()                                    credits = int(line_list[1])                                    study_hours = int(line_list[2])                                    grade = grade_map.get((Study_hours / credits), "invalid")                                    if (credits > 0) and (credits <= 55) and (0 <= study_hours <= 168) and (grade != "Invalid"):#validating data to make sure it is within range                                           writeFile.write("Full Name: " + name.capitalized() + "\n")#if data is validated it will write the data to HowManyHours.txt                                           writeFile.write("Grade: " +grade+ "\n")                                           writeFile.write("Credits: " +str(credits) + "\n")                                           writeFile.write("Weekly Study Hours: " +str(study_hours) + "\n")                                    elif (credits < 0) or (credits > 55):                                           print("You entered " +str(credits) + "which is an incorrect value for credits. Try again.")                                           credits = int(input("Please enter the number of credits you are taking such as 3 for 3 credits."))                                           grade = grade_map.get((study_hours / credits), "Invalid")                                           writeFile.write("Full Name:" +name.capitalized()+"\n")                                           writeFile.write("Grade:" + grade + "\n")                                           writeFile.write("Credits:" +str(credits) + "\n")                                           writeFile.write("Weekly Study Hours:" + str(study_hours) + "\n")                                    else:                                           print("Invalid data format")        except ValueError:              print("Invalid data format. Please make sure the credits and study hours are integers.")                file.close()        writeFile.close() Traceback (most recent call last):   File "C:\Users\User\OneDrive\Desktop\F\FinalProject.py", line 191, in     choice_option[ch]()   File "C:\Users\User\OneDrive\Desktop\F\FinalProject.py", line 120, in determine_grade     credits = int(line_list[1]) IndexError: list index out of range Please help with the errors. Attached is the txt files the program is pulling from.

Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
icon
Related questions
Question

def determine_grade():
       try:#creating this block to handle any exceptions that might occur when trying to convert.
              with open("Grades.txt", "r") as file:#open Grades to read data
                     with open ("HowManyHours.txt", "a") as writeFile:#append data to HowManyHours
                            grade_map = {15:"A",12:"B",9:"C",6:"D",0:"F"}#defining the dictionary
                            for line in file:
                                   line_list = line.strip().split(",")#splitting lines into a list
                                   name = line_list[0].title()
                                   credits = int(line_list[1])
                                   study_hours = int(line_list[2])
                                   grade = grade_map.get((Study_hours / credits), "invalid")
                                   if (credits > 0) and (credits <= 55) and (0 <= study_hours <= 168) and (grade != "Invalid"):#validating data to make sure it is within range
                                          writeFile.write("Full Name: " + name.capitalized() + "\n")#if data is validated it will write the data to HowManyHours.txt
                                          writeFile.write("Grade: " +grade+ "\n")
                                          writeFile.write("Credits: " +str(credits) + "\n")
                                          writeFile.write("Weekly Study Hours: " +str(study_hours) + "\n")
                                   elif (credits < 0) or (credits > 55):
                                          print("You entered " +str(credits) + "which is an incorrect value for credits. Try again.")
                                          credits = int(input("Please enter the number of credits you are taking such as 3 for 3 credits."))
                                          grade = grade_map.get((study_hours / credits), "Invalid")
                                          writeFile.write("Full Name:" +name.capitalized()+"\n")
                                          writeFile.write("Grade:" + grade + "\n")
                                          writeFile.write("Credits:" +str(credits) + "\n")
                                          writeFile.write("Weekly Study Hours:" + str(study_hours) + "\n")
                                   else:
                                          print("Invalid data format")
       except ValueError:
             print("Invalid data format. Please make sure the credits and study hours are integers.")
       

       file.close()
       writeFile.close()

Traceback (most recent call last):
  File "C:\Users\User\OneDrive\Desktop\F\FinalProject.py", line 191, in <module>
    choice_option[ch]()
  File "C:\Users\User\OneDrive\Desktop\F\FinalProject.py", line 120, in determine_grade
    credits = int(line_list[1])
IndexError: list index out of range

Please help with the errors. Attached is the txt files the program is pulling from. 

Grades - Notepad
File Edit Format View Help
Patrick Mahomes
12
36
DeSHaun WATSON
9
apple
drew BREES
55
15
JULIO JONES
15
45
PETER griffin
12
30
Stewey Griffin
15
45
Steven UNIVERSE
9
15
Ringo STARR
18
30
Billy BEAUTY
6
15
Sam Smith
9
30
A
Type here to search
O
jo
(99+
Ln 1, Col 1
100%
Rain...
Windows (CRLF)
0
I
0
UTF-8
9:36 AM
1/25/2023
X
125
Transcribed Image Text:Grades - Notepad File Edit Format View Help Patrick Mahomes 12 36 DeSHaun WATSON 9 apple drew BREES 55 15 JULIO JONES 15 45 PETER griffin 12 30 Stewey Griffin 15 45 Steven UNIVERSE 9 15 Ringo STARR 18 30 Billy BEAUTY 6 15 Sam Smith 9 30 A Type here to search O jo (99+ Ln 1, Col 1 100% Rain... Windows (CRLF) 0 I 0 UTF-8 9:36 AM 1/25/2023 X 125
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
tyREEK hill
12
C
MIKE gisecki
21
A
DREW brees
12
B
AJ Mccarron
15
C
Mac JONES
9
A
A
Type here to search
O
jo
(99+
Ln 1, Col 1
100%
Rain...
Windows (CRLF)
0
I
0
UTF-8
9:30 AM
1/25/2023
X
125
Transcribed Image Text: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 tyREEK hill 12 C MIKE gisecki 21 A DREW brees 12 B AJ Mccarron 15 C Mac JONES 9 A A Type here to search O jo (99+ Ln 1, Col 1 100% Rain... Windows (CRLF) 0 I 0 UTF-8 9:30 AM 1/25/2023 X 125
Expert Solution
steps

Step by step

Solved in 5 steps

Blurred answer
Knowledge Booster
Operations of Linked List
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
Database System Concepts
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
Starting Out with Python (4th Edition)
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
C How to Program (8th Edition)
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
Database Systems: Design, Implementation, & Manag…
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
Programmable Logic Controllers
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education