- import random
- from collections import Counter
- l = [random.randint(0,9) for i in range(10)]
- print (l)
- print(Counter(l).most_common())
- print(Counter(l).most_common(1))
Exemple de résultat
[6, 6, 0, 4, 8, 7, 6, 4, 7, 5]
[(6, 3), (4, 2), (7, 2), (0, 1), (8, 1), (5, 1)]
[(6, 3)]