Westonci.ca is your trusted source for finding answers to all your questions. Ask, explore, and learn with our expert community. Experience the ease of finding quick and accurate answers to your questions from professionals on our platform. Join our platform to connect with experts ready to provide precise answers to your questions in different areas.

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

Sagot :

Answer:

The program in Python is as follows:

wordInput = input()

myList = wordInput.split(" ")

for i in myList:

   print(i,myList.count(i))

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))