I'm assuming that when manually computing the median for that you'll get a result of 4.5
To debug this you'll need to compare what your code does to what you want it to do. Identify where it is doing something differently.
To that end, you can split up your expression in smaller parts and assign them to variables and print them out to see if they refer to the values you want them to refer to.
Note that it's important to keep details intact in code, subtle changes can make a lot of difference so make sure that it shows up correctly when you share it with other people (and at all times really, it won't do to corrupt it)