I don’t know what seem to the issue with my code, here"s the instruction;
Define a function, grades_average, below the grades_sum function that does the following:
Has one argument, grades_input, a list
Calls grades_sum with grades_input
Computes the average of the grades by dividing that sum by float(len(grades_input)).
Returns the average.
Call the newly created grades_average function with the list of grades and print the result.
Here’s my code:
grades = [100, 100, 90, 40, 80, 100, 85, 70, 90, 65, 90, 85, 50.5]
#total = 0
total = 0
for grade in scores:
total += grade
print grades_sum( grades )
sum_of_grades = grades_sum(grades)
average = sum_of_grades / float(len(grades))
Here’s the error message am getting:
grades_average() returned 80.42307692307692 instead of the expected: 3.0.
Am just not getting the strategy in this function definitions, is there any additional trick that I need to learn???