briiiii8719 briiiii8719
  • 03-07-2021
  • Computers and Technology
contestada

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

Respuesta :

MrRoyal
MrRoyal MrRoyal
  • 03-07-2021

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

Answer Link

Otras preguntas

Why would the population of rabbits decrease if the population of mice decreased?
Social security was created during the Great Depression of the 1950s. true or false? i feel it is TRUE..
To convey his ideas and achieve his purpose, Chief Joseph uses a. colloquial language and complex sentences b. elevated diction and dialogue c. difficult words
When there is a national debt, there is less confidence in the economy. true or false?
Did Thomas Jefferson favor a national bank
The base area of the prism is 120 square feet. Its height is 5 feet what is the volume of the prism.
On the Southern Plateau, the desert which covers much of Botswana is called the _____ Desert. Kalahari Gobi Mojave Sahara
The genetic information in human and chimpanzee DNA shows a high degree of similarity, as humans share about 96-99% of their DNA code with chimpanzees. What is
What do these lines from Sophocles's Antigone tell us about Antigone's character?
Please can someone solve 8n + 6 = 4n + 30