[Tutor] Getting multi-line input from user
wormwood_3 at yahoo.com
Wed Jan 7 04:18:12 CET 2009
I'd like to prompt the user for input and get back multiple lines, for example if someone wanted to enter a few paragraphs. Then I'd like to be able to print their input out and preserve formatting. Here's what I have so far:
control = True
user_input = 
if not user_input:
entry = raw_input("Enter text, 'done' on its own line to quit: \n")
entry = raw_input("")
if entry == "done":
control = False
user_input = ' '.join(user_input)
So you end up with:
Enter text, 'done' on its own line to quit:
I am some text.
And I am more.
I am a new paragraph.
I am some text. And I am more. I am a new paragraph.
1) Is there a more elegant/common way to get multi-line user input than this sort of thing?
2) How can I combine and print the output so that paragraphs and the like are preserved?
Homepage - http://samuelhuckins.com
Tech blog - http://dancingpenguinsoflight.com/
Photos - http://www.flickr.com/photos/samuelhuckins/
AIM - samushack | Gtalk - samushack | Skype - shuckins
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the Tutor