[Tutor] Getting multi-line input from user
Andre Engels
andreengels at gmail.com
Wed Jan 7 07:19:23 CET 2009
On Wed, Jan 7, 2009 at 4:31 AM, wormwood_3 <wormwood_3 at yahoo.com> wrote:
> On point 2, say I enter:
> Enter text, 'done' on its own line to quit:
> I am a sentence. I am another sentence.
>
> I am a new paragraph.
> done
>
> What I get out is:
> I am a sentence. I am another sentence. I am a new paragraph.
>
> But that just shows the double new lines of my new paragraph as an extra
> space. I'd like to print it out so it appears just as it was typed in, with
> appropriate newlines.
The newline character is written \n in Python, so if you replace
' '.join(user_input)
by
'\n'.join(user_input)
you should be getting what you want.
--
André Engels, andreengels at gmail.com
More information about the Tutor
mailing list