Bug in Exam statistic? Not seeing it


#1



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


My code looks correct to me and it runs the sum in my jypter notebook but i still keep getting an error.

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

The indentation is not correct above it needs to be re done in jyputer withs tabs.

In[1] : grades_sum([53,7,79]). Out[1]: 139

Oops, try again. It looks like your grades_sum function doesn't properly compute the sum of all the grades! It returned None instead of 139 for grades_sum([53, 7, 79])

am I missing some sort of bug? Hi!!


#2

Never mind I figured it out. It wanted me to print out the grades_sum function at the end which is totally unnecessary but whatever.


#3

It ignores what you print.
Your function shouldn't be printing anything, it should return its result. For most functions it is very strange behaviour to be printing their results instead of returning them, imagine if you tried to use the + operator and it returned None and printed the result instead, it would be spamming the console and you wouldn't be able to use the result in your code.


#4

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