Okay to be average


#1



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

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

Oops, try again. average([3, 0]) returned 3 instead of 1.5 as expected.


Replace this line with your code.


Stuck on an instructions-induced "roadblock"
#2

Here-


#3

there is still same error if i use that statement in the code


#4

The devil was down there...
float(total)/len(numbers)

You're not assigning it again to total.

update**
Hint--

x = 3
x = x + 5

Hope it helps! :slight_smile:


#5

Hi friend,

Your code: float(total)/len(numbers)
Have to a variable contain the result. Change above code to:
total = float(total) / len(numbers)

Have fun!


#6

Add your function below!

def average(numbers):
total=sum(numbers)
total=float(total)
total= total/len(numbers)
return total


#7

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