# Part of the Whole | Problem

#1

Hi, im gentting this message every time I press "Save & Submit Code":
Traceback (most recent call last):
File "python/cli_runner.py", line 152, in
What should I do ?

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 = 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.10 * average(student["homework"]) + 0.30 * average(student["quizzes"]) + 0.60 * average(student["tests"])

if score >= 90: return "A"

def get_class_average(students):
results = ()

``````if score >= 80: return "B"
elif score >= 70: return "C"
elif score >= 60: return "D"
else: return "F"

def get_class_average(students):
results = []
for student in students：
results.append(get_average(student))
return average(results)

#2

Please post your code with proper formatting. Select your code and click `</>` icon in the toolbar above the text area.

#3

Hi, im gentting this message every time I press "Save & Submit Code":
Traceback (most recent call last):
File "python/cli_runner.py", line 152, in
What should I do ?

``````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 = 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.10 * average(student["homework"]) + 0.30 * average(student["quizzes"]) + 0.60 * average(student["tests"])

if score >= 90: return "A"

def get_class_average(students):
results = ()

if score >= 80: return "B"
elif score >= 70: return "C"
elif score >= 60: return "D"
else: return "F"
def get_class_average(students):
results = []
for student in students：
results.append(get_average(student))
return average(results)``````

Is this OK ?

#4

Does it look like in the editor? All the indentations are gone and they are really important. Please copy code from the editor (in the exercise) and try to paste it again.

Good work with formatting, though!

#5

``````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 = 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.10 * average(student["homework"]) + 0.30 * average(student["quizzes"]) + 0.60 * average(student["tests"])

if score >= 90: return "A"

def get_class_average(students):
results = ()

if score >= 80: return "B"
elif score >= 70: return "C"
elif score >= 60: return "D"
else: return "F"

def get_class_average(students):
results = []
for student in students：
results.append(get_average(student))
return average(results)``````

I copied the exercise
If this doesnt work I can send an image

#6

No need to, it's perfect now

Take a look at this part of code:

``````def get_class_average(students):
results = []
for student in students：
results.append(get_average(student))
return average(results)``````

There are two problems:

1. `for` should not be indented. We indent lines when we want to start a new block of code (block of function, `for` loop, `while` loop, `if`...)
2. `return` statement is outside the function. You have to increase indentation level. `return` is part of the function definition and it is used to specify what value the function should return.

``````def get_class_average(students):
results = []
for student in students:
results.append(get_average(student))
return average(results)``````

#7

Sorry, but the problem didn't get solved. Ive refreshed like 5 times and its still says that "something went wrong"

(sorry for bad english, its not my main language)

#8

Hm, I have copied your code and there is a one strange thing, here:

``for student in students：``

This colon is not... a normal colon. Please delete this line and use a normal colon `:`.

#9

Oh god... Thank you very much! Didn't realize that

#10

It slipped through my attention, sorry about that

You're very welcome

#11

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