Median. Odd Error


#1



https://www.codecademy.com/en/courses/python-intermediate-en-rCQKw/2/5?curriculum_id=4f89dab3d788890003000096#


File "python", line 5
else:
^
SyntaxError: invalid syntax


I don't understand why it says there is something wrong with my else statement. Please help for future clarification

Replace this line with your code. 
def median(numbers):
    sorted_num = sorted(numbers)
    if len(sorted_num) % 2 == 0:
        return sorted_num[len(sorted_num / 2)
    else:
        return sorted_num[(len(sorted_num / 2) + \
        len((sorted_num / 2) - 1)) / 2]


#2

Nevermind guys. I just forgot a closing bracket on the line before the else.


#3

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