Finding most frequent elements

PHOTO EMBED

Tue Nov 07 2023 17:14:00 GMT+0000 (Coordinated Universal Time)

Saved by @knguyencookie

from collections import Counter

my_list = [1, 2, 3, 4, 2, 3, 2, 4, 1, 2, 2]

most_common_element = Counter(my_list).most_common(1)[0][0]

print(most_common_element)
content_copyCOPY

https://medium.com/@hannanmentor/pythons-best-code-snippets-c34ed1f07239