I wrote my code out and it keeps telling me that with the list [4,5,5,4] returns a value of 4 instead of 4.5. I did the math that my code should be doing, and it should be returning 4.5. I went and plugged my code into Visual Studio and I got 4.5. But Codecademy is getting 4. I’m at a loss.
def median(original): newList = sorted(original) result = 0 varA = int(len(newList) / 2 - 1) varB = int(varA + 1) if len(newList) < 2: result = newList elif len(newList) % 2 == 0: result = (newList[varA] + newList[varB]) / 2 else: result = newList[varB] return result