Hi,
I’m very new at coding, I’m working to be Data Analyst this year
I’m following the “Data Science : Analytics” path on Codecademy. In the coding exam, I’m struggling with this question :
The following dictionary contains the test scores of students in three different components of an exam:
test_scores = {“Gina”:[80, 72, 90], “Javed”:[88, 68, 81], “Siobhan”:[80, 82, 84], “Pedro”:[98, 96, 95], “Marcel”:[78, 80, 78], “Dilip”:[64, 60, 75]}
However, the teacher realizes that there was an error in one of the questions in the first component of the exam.
Modify test_scores to reflect this change by adding 1 point to the first component of each student’s exam. (Hint: use a for loop!)
Write it into a text file, modified_scores.txt.
My code was :
test_scores = {“Gina”:[80, 72, 90], “Javed”:[88, 68, 81], “Siobhan”:[80, 82, 84], “Pedro”:[98, 96, 95], “Marcel”:[78, 80, 78], “Dilip”:[64, 60, 75]}
print(test_scores)
Modify dictionary
for student, scores in test_scores.items():
scores[0] += 1
print(test_scores)
Write to a text file
with open(“modified_scores.txt”, “w”) as f:
for student, scores in test_scores.items():
f.write(f"{student}: {scores}\n")
But for the text file part, I’ve this error message :
{“passed”:false, “errorMessage”: “Did you write the modified scores to the modified_scores.txt ?”} {“passed”: false, “errorMessage”: “Expected new file modified_scores.txt to be created.”}
I’ve tried tons of responses but all ended with this error message.
Somebody can help me or explain to me ?
Thanks for you’re help !