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

3x + 2y = 6 2x + 5y = 7
What property does the equation 6x=72 have
6-The founder and former CEO of Jones​ Soda, Peter van​ Stolk, claimed that sharing the core values of your loyal customer base is just good for business. If yo
What is shaken baby syndrome, its causes, symptoms, the affected age group, and the long-term effects?
Slope intercept form of y=-1/7x+22/7
Please answer the side questions and the "#justkeepswimming" thank you if you do!!!
which situation best illustrates a violation of the rule of law? A. supreme court justices pay their taxes just as ordinary citizens do B. Congress has suffici
What are the characteristics of a good (effective) window cleaner?
How do the Quran and sharia guide Muslim
Our physical state can affect our mental and emotional health.