why is this not working?

```
def median(n):
x=sorted(n)
if len(x) == 1:
median = x[0]
elif len(x) % 2 ==0:
median = (x[len(n)/2]+x[(len(n)/2)-1])/2
else:
median = x[(len(n)-1)/2]
return median
```

why is this not working?

```
def median(n):
x=sorted(n)
if len(x) == 1:
median = x[0]
elif len(x) % 2 ==0:
median = (x[len(n)/2]+x[(len(n)/2)-1])/2
else:
median = x[(len(n)-1)/2]
return median
```

dividing an integer by an integer will result in a integer, if needs be, the number is floored. You will need to do something with float

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