Question: Write a Python function that counts and returns the number of words in a line of text. Use the function to count the number

Write a Python function that counts and returns the number of words

Write a Python function that counts and returns the number of words in a line of text. Use the function to count the number of words for each line in the following list, as well as the total number of words in the entire list. shakespeare = [ "Be not afraid of greatness", "Some are born great", "some achieve greatness", "and others have greatness thrust upon them"] Print each line of the text with its subtotal. Print the total for the entire list. Format each line, The printed output should look like this: Be not afraid of greatness Some are born great some achieve greatness and others have greatness thrust upon them Total: 19 5437 7

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock

Here is a Python function that counts and returns the number of words in ... View full answer

blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!