Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Your assignment is to write a function called justify. This function is passed 2

ID: 3565285 • Letter: Y

Question

Your assignment is to write a function called justify. This function is passed 2 parameters: an input file and an output file. When the function is completed, the output file should contain the text from the input file formatted in the following way: Punctuation marks are preserved as they appear There should be exactly one blank or one ' n' between each word, not counting any punctuation (which should be preserved as is) There are no more than 80 characters on each line Each line contains as many words as possible prior to the ' ' at the end of the line Example input and output files can be found in the dropbox for this assignment, assuming that justify is called as follows: justify('hw4.txt', 'just.txt')

Explanation / Answer

import textwrap

with open ("data.txt", "r") as ipfile:
data=myfile.read()

ipfile.close()

edited_data = textwrap.fill(data, width = 80)

with open ("just.txt", "wb") as opfile:
   opfile.write(edited_data)
opfile.close()

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote