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

A non-metal usually forms 2 covalent bonds in its compounds.How many electrons will it take in its valence shell?
step by step how to solve 3y + 5.2 = 2 - 5y
Stem-and-Leaf Plots question: How many swimmers were younger then 30 Stem -- Leaf 0 1-- 1 2-- 3,9 3 --
Let E and F be independent events in a sample space S with Pr[E] = 0.4 and Pr[F] = 0.2. Find Pr[EUF] A.0.60 B.0.52 C.0.40 D.0.32 E.0.08
what is the main functions of lipids?
What phylum has animals with a central cavity and mouth;and most of them have tentacles?
Stem-and-Leaf Plots question: How many swimmers were younger then 30 Stem -- Leaf 0 1-- 1 2-- 3,9 3 --
How do you calculate the initial speed given time and displacement? The question is: The longest kick in CFL history was 83.2m. If the ball remained in the air
why are quebec and ontario known as canadas economic heart
express each number in fraction form before finding the inverse:7,10,1 3/4,