1

If I have a large multiline input and I run this line:

story = input() 

it reads it as two inputs and my program doesn't process it correctly. I found a fix on stackoverflow that I modified to look like this:

story = []
while True:
    try:
        line = input()
    except EOFError:
        break
    story.append(line)
story = ' '.join(story)

But I would need to use ctrl+D to induce an EOFError to stop the input. Is there a more intuitive way on Python to copy paste a large multiline input?

  • see https://stackoverflow.com/questions/30239092/how-to-get-multiline-input-from-user – coderoftheday Dec 27 '20 at 00:32
  • 1
    if you paste your input in a file then, you can directly read the file without having to manually induce EOF Error. – vighnesh153 Dec 27 '20 at 00:32
  • if you will have data in file then you can redirect `script.py < file.txt` or on Linux even `cat file.txt | script.py` and it should send `EOF` automatically. – furas Dec 27 '20 at 01:41

0 Answers0