I don't know what is wrong


#1

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

Error message: "Oops, try again. It looks like your grades_sum function doesn't properly compute the sum of all the grades! It returned 28 instead of 264 for grades_sum([28, 98, 4, 22, 18, 94])"

Can someone explain me what is wrong with my code ?!?
def grades_sum(scores):
total = 0
for score in scores:
total += score
return total


#3

Stopped on the first iteration. This indicates that the return must be inside the loop.


#4


#5

Exactly as suspected. Set the return statement to line up with the for so the loop has a chance to complete all iterations.


#6

Thank you, i forgot to add print! :smiley:


#7

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