Answer to Question #174669 in Python for bhuvanesh

Question #174669

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.


1
Expert's answer
2021-03-25T02:02:43-0400
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))

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS