Jan-13-2017, 05:10 PM
(Jan-13-2017, 04:04 PM)Saif133 Wrote: I have to do it in just one lineI do not believe that this is a requirement of your assignment.
Teachers aren't in the habit of asking students to write convoluted one liners.
Even if it is, figure out how to do it first; then worry about compressing it.
First question is, what modules can you use?
If you are allowed to use the
textwrap
module for instance then I guess you can indeed do it in one line but that is just because someone else wrote it somewhere else.So if the goal of the assignment is to use all tools at your disposal (as one would in real life) look into text wrap. Otherwise, we need to start writing some actual code.
https://docs.python.org/3/library/textwrap.html