15/15


#1

def median(lis):
sort=sorted(lis)
if len(sort)==1:
answer= sort[0]
elif len(sort)%2==0:
answer = (sort[len(sort)/2]+sort[1+(len(sort)/2)]/2.0
else :
answer = sort[(len(sort)/2)+1]
return answer

i keep getting he error
File “python”, line 7
else :
^
SyntaxError: invalid syntax

???


#2


#3

when getting a syntax error like this, also pay attention to the line above the error message line


#4

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