# Help needed: My code keeps returning "None" at the end of my printed results

#1

Good day,

I wrote my little program as follows:
total = 0
for i in scores:
total = total + i
print total

This works well except for the fact that it prints the total and then in the next line it prints "None"

How do I get rid of this "None"?

Kind Regards,
Ruan
`

#2

Hi @krulbeer,

For your function to be useful, you should have this ...

``    return total``

``    print total``

This will enable other functions that you write in subsequent exercises to use the result from the `grades_sum` function. The console might still display `None`, but that is just a result of Codecademy's processing of your code.

#3

Hello @appylpye,

Thank you for your quick feedback!

The task that I am busy with (Exam Statistics - the sum of scores) requires printing the result. I therefore need to print it instead of just returning it.

My issue is that it is printing the correct result but when Python assess my output, it sees the "None" as the last output and then returns with "your answer returns None instead of 123..." (or whatever the sum then is).

Any further suggestions?

Kind Regards,
Ruan

#4

The instructions include the following, regarding what the function should do ...

Returns the computed sum

Therefore, you need to include the `return` statement ...

``    return total``

As far as the `print` statement is concerned, there is this ...

Call the newly created `grades_sum()` function with the list of `grades` and `print` the result.

The best strategy would be to not include a `print` statement within the function. Instead, use the following `print` statement outside the function to display the result ...

``print grades_sum(grades)``

Make sure that statement is not indented.

#5

Hello @appylpye,

Thank you very much for your great help!

It worked perfectly!

Thanks,
Ruan

#6