Part of the Whole 'list' object is not callable error


What does this error mean? The console has an output of B but i get this error:
Oops, try again. get_class_average([alice]) resulted in an error: 'list' object is not callable

lloyd = {
    "name": "Lloyd",
    "homework": [90.0, 97.0, 75.0, 92.0],
    "quizzes": [88.0, 40.0, 94.0],
    "tests": [75.0, 90.0]
alice = {
    "name": "Alice",
    "homework": [100.0, 92.0, 98.0, 100.0],
    "quizzes": [82.0, 83.0, 91.0],
    "tests": [89.0, 97.0]
tyler = {
    "name": "Tyler",
    "homework": [0.0, 87.0, 75.0, 22.0],
    "quizzes": [0.0, 75.0, 78.0],
    "tests": [100.0, 100.0]

def average(numbers):
    total = sum(numbers)
    total = float(total)
    return total/len(numbers)
def get_average(student):
    homework = average(student["homework"])
    quizzes = average(student["quizzes"])
    tests = average(student["tests"])
    return 0.1*homework+.3*quizzes+.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"
        return "F"

print get_letter_grade(get_average(lloyd))

def get_class_average(students):
    results = ()
    #students = ["lloyd", "alice", "tyler"]
    for student in students():
    return average(results)


Problem is here:

for student in students():

students is the plain value - a list. We use a pair of the parenthesis to call the functions (and methods) and to pass the arguments. List is not a function -> list is not callable :slight_smile:


Thanks for the feedback!

When I remove the parenthesis after students i get a new error.

get_class_average([alice]) resulted in an error: 'function' object has no attribute 'getitem'

I've searched the forums for this error but can't find a fix that works for my code.

Another question, at risk of sounding stupid or missing something obvious: Since my list students is commented out, how does python 'know' which variables/lists I am referring to in the line: get_class_average(students): ?


This is setting results as an empty tuple. It should rightly be a list, [].

This list can be written just under the three dictionaries at top. Keep in mind that lloyd, alice, and tyler are object identifiers, not strings. Remove the quotes.

@factoradic covered this one, already.

.append() is a method, not a list.



Thanks for the help. My code is finally working! I was mixing up a lot of square brackets and parentheses.