Question
Python script to seperate a poem into 1 lines. I need help writing the basic structure of a Python script that will accept a poem
Python script to seperate a poem into 1 lines. I need help writing the basic structure of a Python script that will accept a poem as an input file and then break it down into a single line output text.
Input as text file:
Jabberwocky by Lewis Carroll (from Through the Looking-Glass and What Alice Found There, 1872)
`Twas brillig, and the slithy toves Did gyre and gimble in the wabe: All mimsy were the borogoves, And the mome raths outgrabe.
"Beware the Jabberwock, my son! The jaws that bite, the claws that catch! Beware the Jubjub bird, and shun The frumious Bandersnatch!"
He took his vorpal sword in hand: Long time the manxome foe he sought -- So rested he by the Tumtum tree, And stood awhile in thought.
And, as in uffish thought he stood, The Jabberwock, with eyes of flame, Came whiffling through the tulgey wood, And burbled as it came!
One, two! One, two! And through and through The vorpal blade went snicker-snack! He left it dead, and with its head He went galumphing back.
"And, has thou slain the Jabberwock? Come to my arms, my beamish boy! O frabjous day! Callooh! Callay!' He chortled in his joy.
`Twas brillig, and the slithy toves Did gyre and gimble in the wabe; All mimsy were the borogoves, And the mome raths outgrabe.
(please note that every other line has a 4 space indent that does not display itself in this forum post:
ie
`Twas brillig, and the slithy toves (4spaces)Did gyre and gimble in the wabe; All mimsy were the borogoves, (4spaces)And the mome raths outgrabe.
and it needs to have an output text file that looks like:
`Twas brillig, and the slithy toves Did gyre and gimble in the wabe:
etc.
etc.
The basic structure is to read through the file and write out the text of the poem, one word per line.
There are a few things to note about the input file:
The first three lines give the title, author, and source of the poem. They are not part of the poem, proper. Note: This program should work for other poems as well. So, remove three lines, not some given number of characters or words.
There are blank lines within the poem to break it into four-line strophes.
Alternate lines of the poem are indented. This mirrors the rhyme scheme of the poem.
Please make sure that you name the output file jabber-out.txt.
The input and output file names should not include drive or folder information, just the simple names: jabberwocky.txt and jabber-out.txt.
From this point I can work on the harder concepts of the code, I just need help getting it started.
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started