# Sending a Letter- name 'get_letter_grade' not defined

#1

<PLEASE USE THE FOLLOWING TEMPLATE TO HELP YOU CREATE A GREAT POST!>

<Below this line, add a link to the EXACT exercise that you are stuck at.>

<This code gives me NameError: name ‘get_letter_grade’ is not defined as error message.>

```python

This code gives me NameError: name ‘get_letter_grade’ is not defined as error message

This should print the average but not recognizing the function defined. Please someone let me know what is wrong with my codes

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):
total=sum(numbers)
total=float(total)
total/=len(numbers)
return total
def get_average(student):
homework=average(student[“homework”])*0.1
quizzes=average(student[“quizzes”])*0.3
tests=average(student[“tests”])*0.6
avg = homework+ quizzes + tests
return avg
def get_letter_grade(score):
if score>=90.0:
return “A”
elif score>=80.0:
return “B”
elif score>=70.0:
return “C”
elif score>=60.0:
return “D”
else:
return “F”
print get_letter_grade(get_average(lloyd))

``<do not remove the three backticks above>``

#2

@shariya13,
The way you indented
your get_letter_grade() function
it is part of the get_average() function

Try it with

``````def average(numbers):
total=sum(numbers)
total=float(total)
total/=len(numbers)
return total
def get_average(student):
homework=average(student["homework"])*0.1
quizzes=average(student["quizzes"])*0.3
tests=average(student["tests"])*0.6
avg = homework+ quizzes + tests
return avg
def get_letter_grade(score):
if score>=90.0:
return "A"
elif score>=80.0:
return "B"
elif score>=70.0:
return "C"
elif score>=60.0:
return "D"
else:
return "F"
print get_letter_grade(get_average(lloyd))
``````

#3

Thanks Leonhard. I agree that indentation before defining get_letter_grade function is the issue as that worked now for me, however I am trying to understand why It is showing not defined instead indentation error?.