The sum of scores. Shouldn't my code work?


#1



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


Oops, try again. It looks like your grades_sum function doesn't properly compute the sum of all the grades! It returned 61 instead of 292 for grades_sum([61, 4, 68, 35, 44, 3, 77])


Seems like I'm getting returned just the first index of the list not the sum all of them.


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

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


#2

I got this ..... return statement wasn't indented correctly.


#3

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