Why is the average returned incorrect?



Why is the average returned incorrect?


Be sure to write your return statement outside of the loop, otherwise your loop can only possibly run one time before return is executed. As soon as a function executes a return statement, it exits immediately and gives whatever value that is.
Your return statement should be on the same indentation level as the for loop so that it’s inside of the function, but outside of the for loop.

FAQ: Learn Python: Student Becomes the Teacher - Part of the Whole

2 posts were split to a new topic: Student is not defined