stuck at exercise 15 median in python

error message median([6,8,12,2,23])resulted in error :list index out of range.

i don't why it is not working.the first line is def median(l)

```
sl = sorted(l)
c = len(sl)
if c == 1:
return l[0]
if c % 2 == 1:
middle_index = sl[int(c - 1) / 2]
middle_value = sl[middle_index]
return middle_value
else:
middle_index1 = sl[int(c / 2 - 1)]
middle_index2 = sl[int(c / 2)]
middle_value = (middle_index1 + middle_index2) / 2.0
return middle_value
Replace this line with your code.
```