Given a sentence S, write a program to print the frequency of each word in S. The output order should correspond with the word's input order of appearance.
word = input('Enter your sentence here:')
word1 = word.split()
word2 = []
for i in word1:
if i not in word2:
word2.append(i)
word2
for i in word2:
print('Frequency of', i, 'is', word.count(i))
Comments
Leave a comment