I am a first-time learner of python, I understand how to use word frequencies to count the number of each unique variable of a list, like this
sentence = ['hello', 'people', 'are', 'the', 'most', 'common', 'word', 'people', 'use', 'for', 'language ', 'learning']
words_freq ={} #dictionary for the counts
for word in sentence:
if word not in words_freq:
words_freq[word] =1
else:
words_freq[word] +=1
print (words_freq)
however, I wonder how could a word frequencies do on the dictionary by using a double for loop?
for example, I have a dictionary like this
Food = {
2015: ["Apple", "Milk", "Cookie", "Banana", "Orange" ],
2016: ["Potato", "Orange", "Chocolate", "Milk", "Mango"],
2017: ["Fish", "Potato", "Orange", "Mango", "Banana"],
2018: ["Beef", "Pork", "Fish", "Apple", "Cookie"],
2019: ["Pork", "Orange", "Apple", "Mango", "Chocolate"]
}
how to do a word frequencies/count and print something like this? Or store the highest value in list form ? apple : 3 milk : 2 orange : 3 .. .. ..
Foodone you show. If that is not the case, please reword.)