I need a function that returns the most common values from a list. If there is more than one most common value, return all of them.
l = [1, 1, 2, 2, 4]
def most_common(l):
#some code
return common
This should return:
[1, 2]
Since they both appear twice.
I am surprised there is no simple function for this. I have tried collections but can't seem to figure this out.