Word Wrap
I am new to python and I have no idea how to do this...Can you please help me..

For this option, first ask the user what the maximum number of columns for printing will be. ("How wide should the
output be?") Next, the user will enter in a paragraph of text. They may enter it in as many lines as they'd like, and the only way you know they are done typing is that they will enter a completely blank line. Once you have all the output, you can assemble it into the output: each "word" should either fit on the current line within the maximum number of columns, or else you must put the word on the next line and fill the current line with spaces up to the given width.
• a "word" means anything between spaces. he's... multi-­‐tasking on "Sunday" has five words.
• words at the end of one line and the beginning of the next must stay separate words (even though you might not receive a space at the end of the first or beginning of the second line).
• multiple spaces should be replaced with a single space.
• tabs should be treated like space characters.
• place vertical bars on both edges of the text. They do not count towards the max width, but make it
clearer where the border of your document is.
• Extra credit (+1): if a word cannot fit on a line at all, then put as much as you can on the line while still
putting a hyphen as the last character on that line, and then continue with the rest of the word on the next
line.
• Extra Credit (+2): Modify your word-wrap option so that instead of having the user enter in the text
directly, they enter the filename of the text file where the contents should be found. This will allow for
multiple paragraphs; preserve each empty line as a full-width line. We have not covered file I/O yet, but
this is your chance to explore a feature on your own and see if you can figure it out! Be sure to get the
basic program working first, though – both to learn from it, and as insurance that you don't lose points
trying to earn extra points!

Please read the sticky threads
Homework Help

If you have no idea then there is not much that can be done with this problem. I would suggest that you start with something easier where you do have some idea of what to do.

This article has been dead for over six months. Start a new discussion instead.