Https://www.codecademy.com/courses/learn-python/lessons/student-becomes-the-teacher/exercises/its-okay-to-be-average-?action=resume_content_item

https://www.codecademy.com/courses/learn-python/lessons/student-becomes-the-teacher/exercises/its-okay-to-be-average-?action=resume_content_item

There is one line I am confused about-
I initially put sum(numbers) = total but that kept up coming as an error however in the solution it is the other way round : total = sum(numbers)
I don’t understand it. Any help would be appreciated- the error that comes is :SyntaxError: can’t assign to function call

The “assign” a value to a variable the syntax has always been:

variable = 'some value'

in your case, you want to assign the result of calling the sum() function to total variable, so total needs to be on the left side of assign operator (=)

Take a close look at the syntax error, it might look scary, but it tells you can’t assign to function call (sum() is a function call)

2 Likes

The syntax manner is the way that without a error . In order to assign any value its written the other way . :slight_smile:

total = sum(numbers) is correct because debugging rules works that ways

2 Likes