[Tutor] Getting multi-line input from user

Alan Gauld alan.gauld at btinternet.com
Wed Jan 7 09:56:21 CET 2009


"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.

raw_input strips off the newline character created by Enter.
You need to add it back in:

entry = raw_input()
user_input.append(entry+'\n')

HTH,


-- 
Alan Gauld
Author of the Learn to Program web site
http://www.alan-g.me.uk




More information about the Tutor mailing list