How is Everybody Doing?


#1



https://www.codecademy.com/courses/python-beginner-en-qzsCL/1/5?curriculum_id=4f89dab3d788890003000096


Error at the bottom of the screen displays: Oops, try again. One of the following is missing or broken when we tried to use it: alice, lloyd, tyler, students, get_class_average, get_letter_grade
I ALSO have an error in the console:
C
Traceback (most recent call last):
File "python", line 56, in
File "python", line 53, in get_class_average
File "python", line 30, in get_average
TypeError: string indices must be integers, not str


Even using the 'reset code' button continues to produce the bottom-of-page error, and adding those prints causes the other errors to pop up. I've looked at...a vast number of other threads on these problems, but as far as I can see my code looks exactly the same as suggested fixes and still causes these errors. The location of the [students] list does not seem to make a difference, nor does renaming it. I'm extremely confused why the previous code is no longer functioning properly when the previous exercise had no issue with it and THAT code hasn't changed at all.


students = ["lloyd", "alice", "tyler"]
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]
}

# Add your function below!
def average(numbers):
    sum(numbers)
    total = sum(numbers)
    total = float(total)
    grade = total / len(numbers)
    return grade
    
def get_average(students):
    homework = average(students["homework"])
    quizzes = average(students["quizzes"])
    tests = average(students["tests"])
    final_grade = homework * .1 + quizzes * .3 + tests * .6
    return final_grade
    
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"

print get_letter_grade(get_average(tyler))

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

print get_class_average(students)
print get_letter_grade(get_class_average(students))


#2

This is supposed to be a list of reference object pointers, not string lterals (which don't point to anything)..


#3

Interesting. I MADE that change, more than once, trying to get it to work, and it didn't do anything, and now it's working. Well, thank you either way! I'll have to keep that in mind with lists that are intended as reference calls.


#4

4 posts were split to a new topic: String indices must be integer not string


#5