Computer Science, asked by fgfdjkf, 5 months ago

Write a program in python to input a string and count the words in it.
python code please....

Answers

Answered by Anonymous
6

Answer:

{'the': 2, 'jumps': 1, 'brown': 1, 'lazy': 1, 'fox': 1, 'over': 1, 'quick': 1, 'dog.': 1}

Flowchart:

Flowchart: Count the occurrences of each word in a given sentence

Explanation:

please mark me as BRAINLIEST

Answered by Equestriadash
5

The following codes have been written using Python.

Source code:

s = input("Enter your string: ")

nsl = s.split()

for i in nsl:

 print(i, "-", len(i))

Once the user inputs the string, it gets split into different elements, that forms a list in the variable nsl. Once that's done, a loop is started. For every element in the list, the changing variable 'i' takes each element and performs the succeeding operation, which is counting the number of characters in it. This is done using the len() function.

Attachments:
Similar questions