Reputation: 18609
I want to accept new line input in python.
I am trying
s = input('''Enter the paragraph :''')
But when i input paragraph.. on the very first ENTER it stops taking further input lines.
So how to accept newline character as input in Python
and then how to print the paragraph as it is on the screen.?
Upvotes: 1
Views: 3776
Reputation: 202
EDIT: This answer assumes that you are using Python 3. If you are using Python 2.x, use the one provided by Anthon.
Do something like this:
text = ''
while True: # change this condition.
text += input('''Enter the paragraph :''')+'\n' #UPDATED. Appended a \n character.
For example, you want to end the input sequence by an extra newline character, then the code would be:
text = ''
while True:
dummy = input('''Enter the paragraph :''')+'\n'
if dummy=='\n':
break
text += dummy
Upvotes: 1
Reputation: 18609
from Python 3: receive user input including newline characters
i have done the below :
import sys
text = sys.stdin.read()
print(text)
and this make my task.
Upvotes: 1