Question
USE PYTHON (f) Suppose you have a list of strings containing English text, like this: [ Four score and seven years ago, our fathers brought
USE PYTHON
(f) Suppose you have a list of strings containing English text, like this:
[ "Four score and seven years ago, our fathers brought forth on", "this continent a new nation, conceived in liberty and dedicated", "to the proposition that all men are created equal. Now we are", " engaged in a great civil war, testing whether that nation, or any", "nation so conceived and so dedicated, can long endure. " ]
There might be additional spacing or punctuation, as shown in the last two lines above.
(f.1) Write the function print_line_numbers that takes a list of strings and prints each string preceded by a line number:
1: Four score and seven years ago, our fathers brought forth on 2: this continent a new nation, conceived in liberty and dedicated 3: to the proposition that all men are created equal. Now we are 4: engaged in a great civil war, testing whether that nation, or any 5: nation so conceived and so dedicated, can long endure.
If there are 10 lines or more, the text won't line up nicely. Use the format method to print each line number in a five-character-wide field. (A nifty enhancement would be to make the line number field width exactly as long as it has to be to display the longest line number.)
(f.2) Write the function stats that takes a list of strings and prints statistics as follows:
16824 lines in the list 483 empty lines 53.7 average characters per line 65.9 average characters per non-empty line
Follow the formatting shown.
(f.3) Write the function list_of_words that takes a list of strings as above and returns a list of individual words with all white space and punctuation removed (except for apostrophes/single quotes).
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started