This forum is now read-only. Please use our new forums! Go to forums
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.
Answer 53a9bd0c9c4e9d00030006c3
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)
Popular free courses
- Free Course
Learn SQL
In this SQL course, you'll learn how to manage large datasets and analyze real data using the standard data management language.Beginner friendly,4 LessonsLanguage Fluency - Free Course
Learn JavaScript
Learn how to use JavaScript — a powerful and flexible programming language for adding website interactivity.Beginner friendly,11 LessonsLanguage Fluency - Free Course
Learn HTML
Start at the beginning by learning HTML basics — an important foundation for building and editing web pages.Beginner friendly,6 LessonsLanguage Fluency
4 comments
Owen Cuikshank, Thank you! Finally I can get back to learning.
Couldn’t for the life of me figure out why I wasn’t able to assign the variable
THANK YOU!
thank you!!!