I wrote up this code. This works fine with the odd number of items but can't function with even number of items.

```
def median(in_list):
median = 0
sorted_list = sorted(in_list)
count = len(sorted_list)
x = count / 2
if count % 2 == 0:
median = float((sorted_list[x] + sorted_list[x + 1]) / 2)
else:
median = (sorted_list[int(x + 0.5)])
return median
print median([4, 5, 5, 4])
```

I don't know why it cannot calculate the actual median. Any help will be good.