Before you report me for duplicate let me link similar topics which say how to write the code, but don't say how it works:
- How do I read multiple lines of raw input in Python?
- How to get multiline input from user [duplicate]
Now the code to read multiple lines:
'''
input data:
line 1
line 2
line 3
'''
line_holder = []
while True:
line = input("\nPlease paste here lines :\n")
if line:
line_holder.append(line)
else:
break
for line in line_holder:
print(line)
How I understand it:
- loop will repeat until "break" statement
- in input we paste multiple lines which are stored in some kind of queue
- if there is anything in the input queue to work with
- add first value from this queue to list
- if there is nothing, kill the loop with "break"
- finally, print what we added from queue input to list
So if there is a queue of inputs, how else can I reach it? How is it stored on the computer and why do I need to build list, to see it?
So if there is a queue of inputs, how else can I reach it?
As written your loop does not access a queue -
input
takes input fromstdin
... typically data entered from the keyboard by the user.How is it stored on the computer ...?
Assume you are referring to the non-existent queue (see above) but when you append
line
to the list, you are storing that line in the list.... and why do I need to build list, to see it?
You don't - you could just print the line to see it, but if you want to use that data later you have to put it in some kind of container and a list is convenient.