What's wrong with my median code?

I receive:

Oops, try again. median([1]) resulted in an error: list index out of range

```
def median (nums):
s = sorted(nums)
halflen= len(nums)/2.0
if len(s) % 2 == 0 :
median = (s[int(halflen)] + s[int(halflen + 1)]) / 2.0
else:
median = s[int(halflen + 0.5)]
return median
```