The code that I wrote compiles fine, but it tells me the calculation of the median is messed up. I can't figure out what I've done wrong in terms of how the median is calculated--does anyone see something that I don't???
Some more comments in addition to @mtf's insight to bring you back on the right track, it might not be everything, but it gets you closer.
It's true that Python gets compiled in some sense (to byte-code) but the program is executed by another program (a Python interpreter) and the only or at least almost only compile-time checking of your code is syntax. Most crashes therefore happen as the program runs, that's the nature of dynamic languages.
You have a for-loop in your code. How many iterations will it perform? It's not really a loop after all, is it, keep your code clean, remove everything that doesn't have a purpose.
len(lst) % 2 doesn't evaluate to True for even numbers. Consider what % does and consider, or test, what bool(1) is.
length=1 isn't a special case, it's an odd length
Parentheses can help clarify things, but too many is just clutter.
lst() is lst a function, or something else that can be called? Because that is calling lst.
Start by sorting the actual lst given in the parameter:
ordered = sorted(lst)
Then store the length:
count = len(lst) # (or len(ordered) if you used that approach)
Now we can set up the odd/even conditions and return the appropriate median value. For an odd length, the median value will be the floor (integer) that results from integer division:
For an even length, the median is the computed average of the middle two elements. It will be a float, so we'll use float division:
(lst[count/2] + lst[count/2 - 1]) / 2.0
This is what you already have, so sort out the return values and you should be away. Of course, we can further simplify, but get it working correctly first, then refactor/simplify if you feel like a challenge. Remember to return the median values, not a list.
Now as to your question,
This is a built-in function for converting a value to a Boolean. bool(1) will return True. I don't see a need for it in this program and that means the line it is contained in may be removed.
The SCT doesn't test with an empty list, but if you wish your program to test, then return an error message, not a list or other object.