```
def median(alist):
alist = sorted(alist)
length = len(alist)
if length % 2 == 0:
medians = 1
medians = medians * alist[length / 2]
medians = medians * alist[length / 2 - 1]
medians = medians / 2
return medians
else:
print alist
return alist[length / 2 - 1]
```

I get this error :median([4, 5, 5, 4]) returned 10 instead of 4.5

Not sure how it got that result. Can I get some advise?