Median: Else: Syntax Error


Python > Practice Makes Perfect > Median

I get this message when I submit my code:

Oops, try again. Your code did not run to end. Check the console window for errors!

And the console says::

File "python", line 7
SyntaxError: invalid syntax

I can't figure out what the problem is with using else: here.

def median(a):
    seq = sorted(a)
    if len(seq) == 1:
        median = seq[0]
    elif len(seq) % 2 == 0:
        median = float(((seq[len(seq)/2] + seq[(len(seq)/2)-1])/2)
        median = int(ses[len(seq)/2])
    return median

Any light anyone can shed would be much appreciated.



It's still expecting a closing parenthesis


Many thanks ionatan.


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