Answer to Question #317470 in Python for ABCD

Question #317470

Write a python that reads several lines of text and print a table indicating number of one-letter words, two-letter words, etc.appearing in the text.

For example, the phrase; Whether 'tis nobler in the mind to suffer.


The output will be:


Word length Occurrences

1 0

2 2

3 1

4 2 (including 'tis)

5 0

6 2

7 1


1
Expert's answer
2022-03-24T13:22:31-0400
import pandas as pd
words = pd.Series(['Hello', 'World','dd', 'd',
                    ])
print("Given Words:")
print(words)
  
rst = words.map(lambda calc: len(calc))
print("Words counts")
print(rst)

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS