5. Computing the Average , Help please!


#1

I don't know actually what i just did with this code! , i am totally confused.
I NEED YOUR HELP GUYZ :slight_smile:
grades = [100, 100, 90, 40, 80, 100, 85, 70, 90, 65, 90, 85, 50.5]

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

And Here is the required code
def grades_average(grades):
total = 0
grades_sum(grades) / float(len(grades)) = total
return total

    print grades_average(grades)

#2

Hello @boardsurfer92218,

inside of the body of your grades_average function, you have assigned the variable total incorrectly. The variable that is being assigned should always be on the left hand side of the equals sign. And you can make your code more efficient by not declaring anymore variables inside the function body, and just directly returning the result.

Hope this helps you out...

Regards,
Barry Allen (@bartholomewallen)


#3

That's helped me bro , thanks a lot ^_^