[FIXED] The sum of scores bugged: is checking different grades


#1


https://www.codecademy.com/en/courses/python-intermediate-en-7mgOa/1/1?curriculum_id=4f89dab3d788890003000096

The code works perfectly and gets the sum that is expected from the grades however the program doesn't accept it as true and is marking a different list to the one it has given me.

Oops, try again. It looks like your grades_sum function doesn't properly compute the sum of all the grades! It returned 1045.5 instead of 232 for grades_sum([64, 46, 1, 27, 94])

The program is meant to add the grades up and return and print the value and it does this correctly just the code academy is checking its own different arrays.


grades = [100, 100, 90, 40, 80, 100, 85, 70, 90, 65, 90, 85, 50.5]

def grades_sum(scores):
    total = 0
    for x in grades:
        total = total + x
    return total
print grades_sum(grades)


#2

Only thing that I see is that your for loop is checking x in grades, but you want to check x in scored.

grades = [100, 100, 90, 40, 80, 100, 85, 70, 90, 65, 90, 85, 50.5]

def grades_sum(scores):
    total = 0
    for each in scores:
        total = each + total
    return total
    
print grades_sum(grades)

#3

That fixed it! Thank you very much never saw that after like an hour of looking and checking for errors.


#4

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.