This forum is now read-only. Please use our new forums! Go to forums

0 points
over 9 years

# 5/9 "can't assign to function call"

Something seems to be wrong here but I can’t really figure out what. Console window says “File “python”, line 23 - SyntaxError: can’t assign to function call”

I think it’s some little mistake I haven’t noticed, any help would be apperciated.

Line 23 = “ sum(numbers) = total “

My code:

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

Instructions:

Write a function average that takes a list of numbers and returns the average.

Define a function called average that has one argument, numbers.

Inside that function, call the built-in sum() function with the numbers list as a parameter.

Store the result in a variable called total.

Like the example above, use float() to convert total and store the result in total.

Divide total by the length of the numbers list. Use the built-in len() function to calculate that.

Return that result.

To assign a variable the variable must be in front of whatever you assigning it to. For example it should be “ total = sum(numbers).”

code

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

points
Submitted by Owen Cruikshank
over 9 years

Owen Cuikshank, Thank you! Finally I can get back to learning.