"get_class_average([alice]) should return a number"


#1

Do not know why the above message is showing. Thank you.

Replace this line with your code. 
class_list = [lloyd, alice, tyler]
# Add your function below!
def average(numbers):
    total = sum(numbers)
    total = float(total)
    avg = total / len(numbers)
    return avg

def get_average(student):
    homework = average(student["homework"])
    quizzes = average(student["quizzes"])
    tests = average(student["tests"])
    return homework * .1 + quizzes * .3 + tests * .6
    


def get_letter_grade(score):
    if score >= 90:
        return "A"
    elif score >= 80 and score < 90:
        return "B"
    elif score >= 70 and score < 80:
        return "C"
    elif score >= 60 and score < 70:
        return "D"
    else:
        return "F"



def get_class_average(students):
    results = []
    for x in class_list:
        calc = get_average(x)
        print calc
    return results

#2

step 4 of the instructions:

Finally, return the result of calling average() with results

i don't see you calling average()?


#3

def get_class_average(students):
    results = []
    for x in class_list:
        calc = get_average
        results.append(calc)
    return average(results)

when I do that, I get the error "Oops, try again. get_class_average([alice]) resulted in an error: unsupported operand type(s) for +: 'int' and 'function' "


#4

don't loop over class_list, loop over the function parameter students instead so your function works for a class of any size (1, 2 (any combi) or 3 students)

here:

calc = get_average

get_average() is also a function call, make it a function call and give it the right argument (think about what the function does and how you should use it here)


#5

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.