def median(numbers): numbers = sorted(numbers) x = len(numbers) if x%2 == 0: t = (numbers[(x//2)-1] + numbers[x // 2]) / 2 return t else: t = numbers[(x - 1) // 2] return t a = [4,5,5,4] b = median(a) print(b)
May we assume you are getting an error message, similar to,
expected 4.5 but got 4
That will return an integer when it should be a float.
This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.