Can’t figure why this isn’t working. Error message is “median([4, 5, 5, 4]) returned 5 instead of 4.5”. Can anyone throw me a hint or two?

```
> def median(sequence):
> result = 0
> x = 0
> med = 0
> sequence.sort()
>
> if len(sequence) % 2 == 0:
> x = len(sequence) / 2
> result = sequence.pop(x)
>
> elif len(sequence) % 2 == 1:
> x = len(sequence) / 2
> med = (len(sequence) / 2) + 1
> if x > 0:
> result = (x + med) / 2
> else:
> result = sequence.pop(0)
>
>
> return result
```