# 6. Just weight and see

#1

Hi guys.
I can't figure out why the error says ''return' out of function' on the last line. Hope you can help!

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):
<> total = float(sum(numbers))
<> average = total / len(numbers)
<> return average

def get_average(student):
<> homework = average(student['homework'])
<> quizzes = average(student['quizzes'])
<> tests = average(student['tests'])

weighted = (homework *0.1) + ( quizzes *0.3) + (tests *0.6)

return weighted

*<> means its indented

#2

@cheeseburgler: If the error message is telling you the your return is out of function, it means there's a problem with your indentation.
Try to fix it and you'll see it will work.

#3

I marked what is indented. Could you check it out, because I still cant find the problem

#4

@cheeseburgler: Almost there!

The return statement should be aligned to the first letter of your function name, at least that's how I do.
Considering there are no if/elif/else statements.

``````def functionTest(argA):
return argA``````

Try to fix that and see how it works!

#5

If i indent the 'return weighted' i get the error message 'unexpected indent'

#6

@cheeseburgler: Copy and paste your code in another compiler, such as repl.it .
Fix the indentation, execute and if everything is working fine, bring it back to your lession.

#7

Figured it out. Had to indent everything below the 'function def get_average(student):'
thanks for the help