From: Alan Gauld
To: tutor@python.org
Sent: Wednesday, January 7, 2009 3:58:18 AM
Subject: Re: [Tutor] Getting multi-line input from user
"Andre Engels" wrote
> The newline character is written \n in Python, so if you replace
>
> '
"Andre Engels" wrote
The newline character is written \n in Python, so if you replace
' '.join(user_input)
by
'\n'.join(user_input)
Yep, that's better than my suggestion of adding
the \n at append time. :-)
Alan G.
___
Tutor maillist - Tu
"wormwood_3" 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 par
On Wed, Jan 7, 2009 at 4:31 AM, wormwood_3 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 tha
>>> For starters you can simplify things a lot:
>>>
>>> user_input = []
>>> entry = raw_input("Enter text, 'done' on its own line to quit: \n")
>>> while entry != "done":
>>>user_input.append(entry)
>>>entry = raw_input("")
>>> user_input = ' '.join(user_input)
>>> print user_input
>>>
>>
wormwood_3 wrote:
Hello everyone,
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 = []
Hello everyone,
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 = []
while control:
if