I'm writing a function that calculates the mode or modes of a list of numbers.
If input is [52, 99, 37, 86, 99, 99, 99, 37, 37, 37]
, output should be [37, 99]
. As you can see smaller number should come first, but my code won't do it. Can someone fix my code?
def mode(L):
most = max(list(map(L.count, L)))
return list(set(filter(lambda x: L.count(x) == most, L)))