You have quite a lot of information that you don't seem to be considering.
To write a program you need to decide what events should take place to produce the desired effect. You have to convince yourself that those events lead up to what you want, and be able to motivate why each event need to happen.
A good place to start is to consider how you yourself would perform this task and analyze how you do it.
The first thing you may want to address is what the loop is meant to accomplish.
If you execute your code manually for a list, in your head, do you then end up with the median for that list?
If you did, then you execute it differently from Python itself. So you would then need to find out where the difference is and what you need to change so that your understanding and what it does is the same.