Question
#opening StudyHours.txt in read mode with open (StudyHours.txt, r) as file1: data = file1.readlines() correct_errors(data)#reading in data and correcting any errors. total_study_hours = 0 for
#opening StudyHours.txt in read mode with open ("StudyHours.txt", "r") as file1: data = file1.readlines() correct_errors(data)#reading in data and correcting any errors. total_study_hours = 0
for record in data: print(record) correction = input("Would you like to correct any errors in this record? (y/n)") if correction == "y": credits = int(record['credits']) grade = record['grade']
if grade == 'A':#determine weekly study hours based on desired grade study_hours = 15 * credits elif grade == 'B': study_hours = 12 * credits elif grade == 'C': study_hours = 9 * credits elif grade == 'D': study_hours = 6 * credits elif grade == 'F': study hours == 0 else: print("Invalid grade for student {record['name']})
Please help me insert an option to the user that allows them to correct any errors in the data after opening StudyHours.txt, we then need to write the CORRECTED code to HowManyHours.txt. Please help me,I think I am on the right track, but i dont know what to put after the " if correction == "y":" statement and how to incorporate it properly into my code because I already had it written prior to this. I just wanna make sure I have the correction code in the right spot and I just need help finishing that small part please. Please provide your answer in Python code. Thank you so much.
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started