Just Weight and See


#1

I'm stuck at this execise and couldn't find a similar topic here, can anyone please help me?

Error: File "python", line 26
def get_average(student):

IndentationError: unindent does not match any outer indentation level

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]
}

# Add your function below!
def average(numbers):
   total= sum(numbers) 
   total=float(total)
   return total/len(numbers)
   
 def get_average(student):
    homework=average(student["homework"])
    quizzes=average(student["quizzes"])
    tests=average(student["tests"])

    return (homework*0.1)+(quizzes*0.3)+(tests*0.6)

#2

well, here:

 def get_average(student):

this line has indent (one space), why?

the error message tells you that there is an indention error, do you not understand the error message python throws at you?


#3

I hadn't realized it! Solved

Thank you!


#4

but the error message tells you this, then you check the line (line number is provided) and notice the space, right?


#5

Yeah, but the arrow was on student so I didn't realize that the problem was before def


#6

never trust the arrow. Just look at the type of error message, and look at the line and line above.


#7

Okay!:+1:
Thank you for helping me
I'm sorry for creating a topic for such a stupid thing


#8

You're welcome

No problem, you have to learn to deal with error messages and stuff. Hope you learned something :slight_smile:


#9

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