Loading...
Loading...
Loading...
Each number in a list is the id of a product in one sale. Print the id that was sold the most times. If several ids tie, print the smallest of them.
Example
Input
6 5 3 5 3 9 5
Output
5
5 appears 3 times.
Try the problem first. Open one hint at a time.
Counting with list.count inside a loop is a hidden double loop. Count everything once with a Counter.
Choose with a key that puts the highest count first and the smaller id second.
Write your Python code, run it on the examples and submit it to hidden tests.
Solve in the editor