I tried this code but it seems to not work, so what is the problem in it?, and what does that error means?
Thanks in advance

Replace this line with your code.


A median is not an average, so for the else case, I would simply,

return x[y]

In the if clause, you are calculating the average of only two values, but it is an average, so semantically your variable name is okay. I would simply,

return ___

Be sure to set the numerator as a float()

return float( ... ) / 2


I know it's not an average, it's just the name.
I tried to set the results to float, but still have the same problem which seems in line 2 "x.sorted()'


For in place sort,


To sort only a copy, not the actual list,

y = sorted(x)


ahaaa, that worked.
Thanks for the great help :")


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