Student Becomes the Teacher


I'm stuck at this exercise.

My code keeps on saying that get_letter_grade seems to be missing when I am printing.

I expect that it shouldn't do this and I'm stuck about how to fix it. Everything else except for the print part seems to be okay.

Replace this line with your code. 
Here is what I have so far. 

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))


Check the indent of your print. It is trying to call get_letter_grade, however, the print will never be reached unless something else calls get_letter_grade.

Hope this helps! If not, feel free to leave a reply and I'll try to go more in-depth.


Could you go a bit more in-depth with that because I don't really understand.


No problem. So where the print statement is right now, it will never be reached. That is because the print statement is inside of the function which means that it won't run until the function does. When the interpreter goes through your code, it looks up-to-down and then left-to-right. The interpreter will never look right until it is told.

If the print statement was moved to the far-left, outside of the function, The print statement will be read, it will call get_letter_grade, the interpreter will find that function, then move into it and begin executing the code that is within it. A function will never be executed unless something else tells the interpreter to do so.


also need to remove the space:
print get_letter_grade**X**(get_average(lloyd))


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