Part of a whole


I triggered an error for the problem child Alice as well. Oops, try again. get_class_average([alice]) should return a number. I only wrote enough code to define the def get_class_average(students): and results = []. I couldnt ever shake Alice even when just checking for indentation.

Part of a Whole

i shook the alice error. Now I have a syntax error. The chevron points to the return but I have return directly under for in a for block statement. Typed and re-typed. Not sure what is invalid about return.

return average(results)
SyntaxError: invalid syntax


def average(numbers):
total = sum(numbers)
total = float(total)
result = total/len(numbers)
return result
def get_average(student):
homework = average(student[“homework”])
quizzes = average(student[“quizzes”])
tests = average(student[“tests”])
return 0.1homework + 0.3quizzes +
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"
result = get_average(lloyd)
def get_class_average(students):
results = []
for student in students:
res = get_average(student)
return average(results)
#this is the working code in the most simpified form…Thank you


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