1words = [
2 'red', 'green', 'black', 'pink', 'black', 'white', 'black', 'eyes',
3 'white', 'black', 'orange', 'pink', 'pink', 'red', 'red', 'white', 'orange',
4 'white', "black", 'pink', 'green', 'green', 'pink', 'green', 'pink',
5 'white', 'orange', "orange", 'red'
6]
7from collections import Counter
8word_counts = Counter(words)
9top_four = word_counts.most_common(4)
10print(top_four)
11
12
1from collections import Counter
2
3a = [1936, 2401, 2916, 4761, 9216, 9216, 9604, 9801]
4
5c = Counter(a)
6
7print(c.most_common(1)) # the one most common element... 2 would mean the 2 most common
8[(9216, 2)] # a set containing the element, and it's count in 'a'