I want to create a Python program which takes in multiple lines of user input. For example:
This is a multilined input.
It has multiple sentences.
Each sentence is on a newline.
How can I take in multiple lines of raw input?
I want to create a Python program which takes in multiple lines of user input. For example:
This is a multilined input.
It has multiple sentences.
Each sentence is on a newline.
How can I take in multiple lines of raw input?
To get every line as a string you can do:
Python 3:
Keep reading lines until the user enters an empty line (or change
stopword
to something else)Alternatively,You can try
sys.stdin.read()
Try this
INPUT:
1
2
3
4
OUTPUT: ['1', '2', '3', '4']
Just extending this answer https://stackoverflow.com/a/11664652/4476612 instead of any stop word you can just check whether a line is there or not
you will get the lines in a list and then join with \n to get in your format.