Alice should return a number - help please!


#1


Please help. I'm stuck on the lesson "Student Becomes the Teacher"

The console box says none, but I get the following error: Oops, try again. get_class_average([alice]) should return a number

I have tried a number of different things and looked through the forums. Nothing seems to work. Any help would be appreciated.

Thank you! I was able to fix the problem.I took out the students list. I also separated results.append() from return average(results) I think the second part did the trick. I'm not sure the students list mattered. ****


def get_class_average(students): #defining the function
    students = [lloyd, alice, tyler] #list containing my students
    results = [] #empty list for results
    for student in students: #for loop 
        get_average(student)
        return results.append(get_average(student))


def get_class_average(students): #defining the function
    results = [] #empty list for results
    for student in students: #for loop 
        get_average(student) #per instructions
        results.append(get_average(student))
    return average(results)


#2

You're not returning the average of the results from what I see so far.


#3

Unindent return so that it lines up with your for loop statement. Indentation is really, really important in Python.


#4

Thanks for the input. I spent an inordinate amount of time on this! :confounded:


#5

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