'Grade Marking Python Program, Not Expected Output [closed]

Here are the rules to my assignment: You have access to a database of student_scores in the format of a dictionary. The keys in student_scores are the names of the students and the values are their exam scores.

Write a program that converts their scores to grades. By the end of your program, you should have a new dictionary called student_grades that should contain student names for keys and their grades for values. The final version of the student_grades dictionary will be checked.

DO NOT modify lines 1-7 to change the existing student_scores dictionary.

This is the scoring criteria:

Scores 91 - 100: Grade = "Outstanding"

Scores 81 - 90: Grade = "Exceeds Expectations"

Scores 71 - 80: Grade = "Acceptable"

Scores 70 or lower: Grade = "Fail"

Expected Output '{'Harry': 'Exceeds Expectations', 'Ron': 'Acceptable', 'Hermione': 'Outstanding', 'Draco': 'Acceptable', 'Neville': 'Fail'}'


Here is my code:

student_scores = {
  "Harry": 81,
  "Ron": 78,
  "Hermione": 99, 
  "Draco": 74,
  "Neville": 62,
}
# 🚨 Don't change the code above 👆

#TODO-1: Create an empty dictionary called "student_grades."


#TODO-2: Write your code below to append the grades to student_grades.👇
student_grades = {}
gradeslist = []
for student in student_scores:
    if student_scores[student] <= 100 and student_scores[student] >= 91:
        gradeslist.append("Outstanding")
    elif student_scores[student] <= 90 and student_scores[student] >= 81:
        gradeslist.append("Exceeds Expectations")
    elif student_scores[student] <= 80 and student_scores[student] >= 71:
        gradeslist.append("Acceptable") 
     
    else:
        gradeslist.append("Fail")  

for key in student_scores:
    for num in range(0, len(student_scores)-1):
        student_grades[key] = gradeslist[num] 
    

# 🚨 Don't change the code below 👇
print(student_grades)


OUTPUT {'Harry': 'Acceptable', 'Ron': 'Acceptable', 'Hermione': 'Acceptable', 'Draco': 'Acceptable', 'Neville': 'Acceptable'}

Why Is This Happening?



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source