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
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.
Here’s the code of the section that’s having an issue (the last 4 lines are indented):
total / len(numbers)
I keep getting this error message:
File “python”, line 20
SyntaxError: invalid syntax
<do not remove the three backticks above>