Syntax error on print()?

I was working on some of the challenges in the python courses, here’s what I wrote:


here’s the output:

File “./python”, line 10
print(middle_element([5, 2, -10, -4, 4, 5]))
SyntaxError: invalid syntax

Hey there @rubyace49604!! Welcome to the Codecademy forums :grinning:

In the future when you post code could you do it properly formatted:

Just push this button at the top of the page:

Then paste your code between the backticks:

This makes it so one can copy your code and paste it in an IDE to run it, and makes it easier to read.

It appears you have an extra opening parenthisis on line 7:

return ((lst[len(lst) / 2 -1] + lst[len(lst) / 2]) / 2

Since there is nothing closing it, an error is thrown on the next line.

There are some other errors in your list indexing, but since you haven’t asked about them I won’t spoil thoughs for you. If you end up needing help feel free to ask. :slightly_smiling_face:

1 Like

I need glasses haha, Thanks for the help and advice!

1 Like