How to check the most common elements in a collection

PHOTO EMBED

Sat Jun 22 2024 18:55:00 GMT+0000 (Coordinated Universal Time)

Saved by @pynerds #python

from collections import Counter

data = ['Java', 'Python', 'Java', 'C++', 'Python', 'PHP', 'C++', 'Java', 'PHP', 'Java', 'Python']

c = Counter(data)

print(c.most_common(3))
content_copyCOPY

https://www.pynerds.com/python-collections-counter/