logo CodeStepByStep logo

mode

Language/Type: Python lists

Write a function named mode that returns the most frequently occurring element of a list of integers. Assume that the list has at least one element and that every element in the list has a value between 0 and 100 inclusive. Break ties by choosing the lower value.

For example, if the list passed contains the values [27, 15, 15, 11, 27], your function should return 15.

Function: Write a Python function as described, not a complete program.

You must log in before you can solve this problem.

Log In

Need help?

Stuck on an exercise? Contact your TA or instructor.

If something seems wrong with our site, please

Is there a problem? Contact us.