Question: this is test code please use python to solve. Exercise 8: Justify any Text Complete the function consistent LineLength' taking two parameters, a fi name,

 this is test code please use python to solve. Exercise 8:

Justify any Text Complete the function consistent LineLength' taking two parameters, a

this is test code

fi name, and a maximum length (i.e., a strictly positive integer number).

please use python to solve.

Exercise 8: Justify any Text Complete the function consistent LineLength' taking two parameters, a fi name, and a maximum length (i.e., a strictly positive integer number). T function opens the file, reads every line, and returns a list of strings whe every string represents a line that is filled as much as possible without ceeding the given maximum length. Example: consider a file containing the following lines from 'Alic Adventures in Wonderland! Alice was beginning to get very tired of sitting by her sister on the bank, and of having nothing to do: once or twice she had peeped into the book her sister was reading, but it had no pictures or conversations in it,"and what is the use of a book," thought Alice, "without pictures or conversations?" The corresponding output for length - 50 would be: ['Alice was beginning to get very tired of sitting', by her sister on the bank, and of having nothing', 'to do: once or twice she had peeped into the book', 6 'her sister was reading, but it had no pictures or', 'conversations in it, "and what is the use of a', 'book," thought Alice, "without pictures or', 'conversations?"'] You do not need to deal with multiple paragraphs of text. That is, you can group together words from different paragraphs. Finally, you can assume that no word is longer than the maximum length. def test_consistent_line_length(): script_dir = os. path.dirname (os.path.abspath(_file_)) input_file = Path(script_dir, "test_data", "text1.txt") assert consistentLineLength(input_file, 50) == [ "Alice was beginning to get very tired of sitting", "by her sister on the bank, and of having nothing", "to do: once or twice she had peeped into the book", "her sister was reading, but it had no pictures or", 'conversations in it, "and what is the use of a', 'book," thought Alice, "without pictures or', conversations?", ] assert consistentLineLength(input_file, 20) == [ "Alice was beginning", "to get very tired of", "sitting by her", "sister on the bank,", "and of having", "nothing to do: once", "or twice she had", "peeped into the book", "her sister was", "reading, but it had", "no pictures or", "conversations in", 'it, "and what is the', 'use of a book,"', "thought Alice,", ""without pictures or', 'conversations

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock 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 Databases Questions!