Answers for "find least frequent word in a list python"

1

most frequent word in a list python

words = [
   'red', 'green', 'black', 'pink', 'black', 'white', 'black', 'eyes',
   'white', 'black', 'orange', 'pink', 'pink', 'red', 'red', 'white', 'orange',
   'white', "black", 'pink', 'green', 'green', 'pink', 'green', 'pink',
   'white', 'orange', "orange", 'red'
]
from collections import Counter
word_counts = Counter(words)
top_four = word_counts.most_common(4)
print(top_four)
Posted by: Guest on September-28-2020
0

Python | Find most frequent element in a list

# Program to find most frequent 
# element in a list
def most_frequent(List):
    return max(set(List), key = List.count)
  
List = [2, 1, 2, 2, 1, 3]
print(most_frequent(List))
Posted by: Guest on July-11-2021

Code answers related to "find least frequent word in a list python"

Python Answers by Framework

Browse Popular Code Answers by Language