Most frequent number

Write code · Challenge · §4.3 Counting occurrences

Complete the function solution, which returns the number that appears most often in the list of integers nums.

If more than one number appears most often, return the smallest of them.

Function

solution(nums)

Constraints

Examples

numsresult
[5, 2, 5, 2, 9]2
[4]4

Starter code

def solution(nums):
    answer = 0
    return answer

Solve this problem in your browser

Python runs in your browser and checks your answer right away. Hints and the answer are on the problem page.