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

Graph ƒ(x) = - x. Click on the graph until the graph of ƒ(x) = - x appears.
how old is nelson mandela?
HELP!!! Is it possible to have a polynomial that has a different degree and a different root? Example?
Based on the transcript what did wells most likely want people to consider after listening to his broadcast?
Eric is observing the velocity of a runner at different times. After one hour, the velocity of the runner is 5 km/h. After three hours, the velocity of the runn
Why did the battle of Okinawa happen?Why was the battle fought?And any more important info you might know about this battle
Find the slope of the line that contains the points (-6,4) and (2,-8).
How many Adams of nitrogen appeared to be on the reactant side
What is the value of b in the equation 3b + 2(b − 1) = 8? A: 2 B: 5 C: 8 D: 10
Which one of the following was a problem caused by the article of confederation