I'm trying to use the Python statistics library but have trouble with median
. As you can see below, the program return the mean
, but the list somehow becomes empty for median
and raises error. Please take a look, and thanks in advance!
import statistics
RawInput = input("Please enter a list separated by commas\n")
lst = RawInput.split(", ")
usable_lst = map(int, lst)
def mean():
print("The mean is " + str(statistics.mean(usable_lst)))
def median():
Sorted = sorted(usable_lst)
print("The median is" + str(statistics.median(Sorted)))
print("The median low is" + str(statistics.median_low(Sorted)))
print("The median high is" + str(statistics.median_high(Sorted)))
def mode():
print("The mode is" + str(statistics.mode(usable_lst)))
mean()
median()
mode()