Cant get whats wrong


#1



dont know whats wrong i think it may be an indentation error but am not quite sure.


https://www.codecademy.com/courses/python-beginner-en-qzsCL/1/5?curriculum_id=4f89dab3d788890003000096


it keeps on saying

One of the following is missing or broken when we tried to use it: alice, lloyd, tyler, students, get_class_average, get_letter_grade

and
File "python", line 46
def get_class_average(students):
^
SyntaxError: invalid syntax


Replace this line with your code. 
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]
}


def average(numbers):
       sum(numbers)
       total=sum(numbers)
       total = float(total)
       return total/len(numbers)
   
def get_average(student):
      return average(student["homework"]) * 0.1 + \
    average(student["quizzes"]) * 0.3 + \
    average(student["tests"]) * 0.6
    
def get_letter_grade(score):
  if score >= 90:
      return "A"
  if score >= 80:
      return "B"
  if score >= 70:
      return "C"
  if score >= 60:
      return "D"
  else:
    return "F"
    get_letter_grade(get_average(lloyd))
    print get_letter_grade(get_average(lloyd)
  
  def get_class_average(students):
    results =[]
    for student in students:
     avg = get_average(student)
     results.append(avg)
     return average(results)
    print average(results)
    students = [alice, lloyd, tyler]
print get_class_average(students))


please help


#2

Python is very particular when it comes to indentation. That is the first problem to solve.


#3

Your indents aren't spaced correctly, try using the tab button the second time around. Also the students list should be defined much earlier. I have fixed your indents and a few other things below:

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]
}
students=[lloyd, alice, tyler]
# Add your function below!
def average(numbers):
#sum of the numbers
    total=(float(sum(numbers)))/len(numbers)
#making the integer a float
#finding average 
#storing it until function is called
    return total
def get_average(student):
    homework = average(student["homework"])
    quiz = average(student["quizzes"])
    test = average(student["tests"])
    return homework * 0.1 + quiz * 0.3 + test * 0.60
def get_letter_grade(score):
    if score >= 90:
        return "A"
    elif score >= 80 and score < 90:
        return "B"
    elif score >= 70 and score < 80:
        return "C"
    elif score >= 60:
        return "D"
    else:    
        return "F"
get_average(lloyd)  
def get_class_average(students):
    results=[]
    for student in students:
        results.append(get_average(student))
    return average(results)
    
print get_class_average(students)
print get_letter_grade(get_class_average(students))

#4

Besides the indentation mentioned. The list Students should be outside the function.


#5

thank you so much you've been very helpful


#6

Welcome! Glad to help. :slight_smile:


#7

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