100,765 views
18 votes
18 votes
Write a program that reads a list of words. Then, the program outputs those words and their frequencies. Ex: If the input is: hey hi Mark hi mark

User Pablo Yaggi
by
3.0k points

1 Answer

13 votes
13 votes

Answer:

The program in Python is as follows:

wordInput = input()

myList = wordInput.split(" ")

for i in myList:

print(i,myList.count(i))

Step-by-step explanation:

This gets input for the word

wordInput = input()

This splits the word into a list using space as the delimiter

myList = wordInput.split(" ")

This iterates through the list

for i in myList:

Print each word and its count

print(i,myList.count(i))

User Genzer
by
2.4k points