5. idk whats going wrong been stuck for a while


#1


Ive had this code in there and idk whats wrong with it.

this is what i get:

File "python", line 22
SyntaxError: can't assign to function call

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


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


#2

here:

sum(numbers) = total

on the left side of the equal sign, is the variable in which you store the information/data on the right side is what you store in that variable, so if you want to store something in total you do:

total = 5

#3

I do this:

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

and I get:

script.py

File "python", line 25
SyntaxError: 'return' outside function

(line 25 is return total line)


#4

nvm i got it. the return had to be tabbed over


#5

good you solved it.

Yep, i saw return was wrongly indented, but i was confident you would be able to figure it out :slight_smile:


#6