Problem creating a definition


#1



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


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


To return the correct total. So 1.5 i guess ?


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

# Add your function below!
def average(numbers):
    total = sum(numbers)
    total = float()
    total = total / len(numbers)
    return total


#2

Hi this line

total = float()

it' s missing somthing do know what?


#3

total = float()

Calling float with no arguments will create a new instance of float and it'll default to 0.0

Similarly, int() returns 0 and str() returns '', list() returns [], bool() returns False ..and so on


#4

hello a friend helped me fix the problem.
My mistake was i put "total = float()" isntead of "total = float(total)". Thank you for the info ionatan :smiley:


#5

it's missing total = float(total).


#6

do i delete my topic when solved ?