Sending a Letter


I am trying to complete the 'Sending a letter' excercise where you compute the letter grades for the three students.

I expect to see grades, but instead keep getting an error message saying that the function is not 'iterable':

Traceback (most recent call last):
File "python", line 44, in <-- line 44 is the last 'Print' statement
File "python", line 33, in get_letter_grade <-- line 33 is "for z in get_letter_grade:"
TypeError: 'function' object is not iterable

I did not expect the last line to return a syntax error, as the 'hint' shows the same line.

MY CODE (minus the student dictionaries):

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

student = [lloyd, alice, tyler]
def get_average(student):
    return 0.10 * average(student["homework"]) + \
    0.30 * average(student["quizzes"]) + \
    0.60 * average(student["tests"])
def get_letter_grade(score):
    for z in get_letter_grade:
        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))



Look at here........


I tried it like three different ways and kept getting the same error...

Then I just commented out that line entirely. That allows the program to run.



You are welcome!:+1:


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