It's Okay to be Average


#1

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

Hi!
I’ve been having an issue with the “It’s Okay to be Average” section of the “Student Becomes a Teacher” lesson. My code seems fine, but I keep getting the same error message when I define the function “average”. What am I doing wrong?

These are the instructions I’m supposed to follow:

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.
Stuck? Get a hint
Community Forums
Get help and ask questions on the Codecademy community forums.

Go to the forums
Report a Bug
If you see a bug or any other issue with this page, please report it here.

```python

Here’s the code of the section that’s having an issue (the last 4 lines are indented):

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

I keep getting this error message:
File “python”, line 20
def average(numbers):
^
SyntaxError: invalid syntax

<do not remove the three backticks above>

#2

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.