How's everybody doing?


I am getting this message:
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 can't figure out what's wrong with the code

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


in your last two lines student should be students


I changed it to students but got this error
Traceback (most recent call last):
File "python", line 52, in
NameError: name 'students' is not defined

oh i changed student =[ lloyd, alice , tyler] to students = [ lloyd, alice ,tyler], along with what u said but why ?


Your last three lines use improper indentation. Keep in mind indentation is extremely important in python.


The indentation in three lines was correct, mate. Actually in question they asked to use students and I was using the name student which was the reason it wasn't working.


I understand that. I was just saying that you're indentation was improper. It is best-practice to always use proper indentation when coding. This is your code:

student = [ lloyd, alice, tyler]
print  get_class_average(student)
print get_letter_grade( get_class_average(student))

This is your code properly indented:

students = [lloyd, alice, tyler]
print get_class_average(students)
print get_letter_grade(get_class_average(students))

Notice the difference?

Improper indentation may not have affected your code this time, but if you don't consistently indent properly, I can assure you it will effect your code somewhere down the line.


Ok mate, got it. Thanks.:slight_smile:


This has got to be my biggest frustration to taking this course. I had the same code except I chose to pass the list thusly get_class_average([lloyd, alice, tyler]) when printing the numerical class average and it worked. When I went to add the code for printing the class letter grade is again passed [lloyd, alice, tyler] to get_class_average. The code printed out everything as expected except I got the error posted above. Placing the list in a variable, creating students, and the error went away. My code wasn't necessarily wrong, just not what the program was looking for. It is frustrating when you can write code that syntactically works and still get an error because what ya did wasn't expected. grrrr I got an error earlier because I used "name": "alice" instead of "name": "Alice"


Yeah, I had to recheck my whole code again and again. Then I thought maybe my concepts aren't clear so I started the whole section only to face the same problem again. All my concepts were shaken. Then I finally realized what the problem was because of this forum.


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