How can I tell what is invalid about my syntax?


#1

Question

How can I tell what is invalid about my syntax?

Answer

If you Run your code and receive an error complaining about your syntax, then you may have made a simple typo somewhere. Python has no way of knowing that grade_sum() was meant to be grades_sum(), if you spelled it differently on accident when calling it vs when you defined it.
Also, be sure to include the word def before a function, a colon : after, and to return after the loop, not inside of it.


FAQ: Learn Python - Exam Statistics - The sum of scores