hello again, I am stuck with median now, below are my code, although I have noticed the rule that in python string and list are indexed from zero, but I still have trouble in calculating the median. The message keeps telling me that [4, 5, 5, 4] cannot apply to my code. But I really cannot figure out where the problem is.
So, if you can help me with this problem, I would be more than glad!
def median(n): sorted(n) if len(n) % 2 != 0: med = n[(len(n) - 1) / 2] else: med1 = n[(len(n) / 2) - 1] med2 = n[(len(n) / 2)] med = (med1 + med2) / 2 return med