Search code examples
pythoninputparagraph

If an input string too id long or has a paragraphs won't copy it all


I have a question about input

description = input('add description: ')

I'm adding a text using Ctrl+C and Ctrl+V.

For example:

"The short story is a crafted form in its own right. Short stories make use of plot, resonance, and other dynamic components as in a novel, but typically to a lesser degree. While the short story is largely distinct from the novel or novella/short novel, authors generally draw from a common pool of literary techniques.

Determining what exactly separates a short story from longer fictional formats is problematic. A classic definition of a short story is that one should be able to read it in one sitting, a point most notably made in Edgar Allan Poe's essay "The Philosophy of Composition" (1846)"

Result is:

description = "The short story is a crafted form in its own right. Short stories make use of plot, resonance, and other dynamic components as in a novel, but typically to a lesser degree. While the short story is largely distinct from the novel or novella/short novel, authors generally draw from a common pool of literary techniques."

Whilst I want description to hold the entire text chain I copied.


Solution

  • Normally the input() function terminates on an End Of Line or \n. I would suggest using a setup like this:

    line = []
    while True:
        line = input()
        if line == "EOF":
            break
        else:
            lines.append(line)
    text = ' '.join(lines)
    

    What this does is read input and add it to a array until you type in "EOF" on its own line and hit enter. Thsis should solve the multi line problem.