Part of the Whole issue


#1



Hi, in the exercise "Part of the Whole", I'm getting the error message below and cannot get around it. I'm sure something is missing and posted my code below if you can help me figure it out. Thanks!


> Oops, try again.
> get_class_average([alice]) should return a number


def average(numbers):
    total = float(sum(numbers)) / len(numbers)
    return total

def get_average(student): 
    homework = average(student["homework"])
    quizzes = average(student["quizzes"])
    tests = average(student["tests"])
    return 0.1 * homework + 0.3 * quizzes + 0.6 * tests
    
def get_letter_grade(score):
     if score >= 90:
         return "A"
     elif score >= 80: 
         return "B"
     elif score >= 70:
         return "C"
     elif score >= 60:
         return "D"
     else:
         return "F"
def get_class_average(students):
    students = [lloyd, alice, tyler]
    results = []
    for student in students:
        return results.append(get_average(student))
    return average(results)


#2

by default a function return None at the end, we can make the function something different by using the return keyword

the catch is, that a function will end when the return keyword is reached

so your function ends a bit prematurely.


#3

When you return the value inside your for loop, you are terminating the function right then and there. In addition, the .append() function has no return value, so you cannot return it, and expect any value other than None.


#4

Thanks, I was able to get it resolved.


#5