Q:

Copying lines from text file- remove formatting- Python

I am attempting to read text from a file, then print out the corresponding Shakespearean sonnet off of input from a user. [if the user enters 1, print sonnet 1, etc.]. 
The code I have below functions, however, I would like the answers to be without all the formatting 
'def serve_poem():
    sonnet=open(r"C:\Users\Emily\Documents\sonnets.txt", "r")
    x=int(input("Please enter a number 1-7:"))
    s=sonnet.readlines()
    s=list(s)
    if x==1:
        print(s[2:16])
    if x==2:
        print(s[21:35])
    if x==3:
        print(s[40:54])
    if x==4:
        print(s[59:73])
    if x==5:
        print(s[78:92])
    if x==6:
        print(s[97:111])
    if x==7:
        print(s[116:130])
    else:
        print("The number you entered is not between 1-7. Please enter 1-7:")
serve_poem()'

(i.e. my returns look like this:)
'''['From fairest creatures we desire increase,\n', " That thereby beauty's rose might never die,\n", ' But as the riper should by time decease,\n', ' His tender heir might bear his memory:\n', ' But thou contracted to thine own bright eyes,\n', " Feed'st thy light's flame with self-substantial fuel,\n", ' Making a famine where abundance lies,\n', ' Thy self thy foe, to thy sweet self too cruel:\n', " Thou that art now the world's fresh ornament,\n", ' And only herald to the gaudy spring,\n', ' Within thine own bud buriest thy content,\n', " And, tender churl, mak'st waste in niggarding:\n", ' Pity the world, or else this glutton be,\n', " To eat the world's due, by the grave and thee.\n"]'''
(Instead of like this:)
'''From fairest creatures we desire increase,
 That thereby beauty's rose might never die,
 But as the riper should by time decease,
 His tender heir might bear his memory:
 But thou contracted to thine own bright eyes,
 Feed'st thy light's flame with self-substantial fuel,
 Making a famine where abundance lies,
 Thy self thy foe, to thy sweet self too cruel:
 Thou that art now the world's fresh ornament,
 And only herald to the gaudy spring,
 Within thine own bud buriest thy content,
 And, tender churl, mak'st waste in niggarding:
 Pity the world, or else this glutton be,
 To eat the world's due, by the grave and thee.'''
I apologize for the length, but here is the original text file:
I.
From fairest creatures we desire increase,
 That thereby beauty's rose might never die,
 But as the riper should by time decease,
 His tender heir might bear his memory:
 But thou contracted to thine own bright eyes,
 Feed'st thy light's flame with self-substantial fuel,
 Making a famine where abundance lies,
 Thy self thy foe, to thy sweet self too cruel:
 Thou that art now the world's fresh ornament,
 And only herald to the gaudy spring,
 Within thine own bud buriest thy content,
 And, tender churl, mak'st waste in niggarding:
 Pity the world, or else this glutton be,
 To eat the world's due, by the grave and thee.
II.
When forty winters shall besiege thy brow,
 And dig deep trenches in thy beauty's field,
 Thy youth's proud livery so gazed on now,
 Will be a totter'd weed of small worth held: 
 Then being asked, where all thy beauty lies,
 Where all the treasure of thy lusty days; 
 To say, within thine own deep sunken eyes,
 Were an all-eating shame, and thriftless praise.
 How much more praise deserv'd thy beauty's use,
 If thou couldst answer 'This fair child of mine
 Shall sum my count, and make my old excuse,'
 Proving his beauty by succession thine!
 This were to be new made when thou art old,
 And see thy blood warm when thou feel'st it cold.
III.
Look in thy glass and tell the face thou viewest
 Now is the time that face should form another;
 Whose fresh repair if now thou not renewest,
 Thou dost beguile the world, unbless some mother.
 For where is she so fair whose uneared womb
 Disdains the tillage of thy husbandry?
 Or who is he so fond will be the tomb
 Of his self-love, to stop posterity? 
 Thou art thy mother's glass and she in thee
 Calls back the lovely April of her prime;
 So thou through windows of thine age shalt see,
 Despite of wrinkles, this thy golden time.
 But if thou live, remembered not to be,
 Die single and thine image dies with thee.
IV.
Unthrifty loveliness, why dost thou spend
 Upon thy self thy beauty's legacy?
 Nature's bequest gives nothing, but doth lend,
 And being frank she lends to those are free:
 Then, beauteous niggard, why dost thou abuse
 The bounteous largess given thee to give?
 Profitless usurer, why dost thou use
 So great a sum of sums, yet canst not live?
 For having traffic with thy self alone,
 Thou of thy self thy sweet self dost deceive:
 Then how when nature calls thee to be gone,
 What acceptable audit canst thou leave?
 Thy unused beauty must be tombed with thee,
 Which, used, lives th' executor to be.
V.
Those hours, that with gentle work did frame
 The lovely gaze where every eye doth dwell,
 Will play the tyrants to the very same
 And that unfair which fairly doth excel;
 For never-resting time leads summer on
 To hideous winter, and confounds him there;
 Sap checked with frost, and lusty leaves quite gone,
 Beauty o'er-snowed and bareness every where:
 Then were not summer's distillation left,
 A liquid prisoner pent in walls of glass,
 Beauty's effect with beauty were bereft,
 Nor it, nor no remembrance what it was:
 But flowers distilled, though they with winter meet,
 Leese but their show; their substance still lives sweet.
VI.
Then let not winter's ragged hand deface,
 In thee thy summer, ere thou be distilled:
 Make sweet some vial; treasure thou some place
 With beauty's treasure ere it be self-killed.
 That use is not forbidden usury,
 Which happies those that pay the willing loan;
 That's for thy self to breed another thee,
 Or ten times happier, be it ten for one;
 Ten times thy self were happier than thou art,
 If ten of thine ten times refigured thee:
 Then what could death do if thou shouldst depart,
 Leaving thee living in posterity?
 Be not self-willed, for thou art much too fair
 To be death's conquest and make worms thine heir.
VII.
Lo! in the orient when the gracious light
 Lifts up his burning head, each under eye
 Doth homage to his new-appearing sight,
 Serving with looks his sacred majesty; 
 And having climbed the steep-up heavenly hill,
 Resembling strong youth in his middle age,
 Yet mortal looks adore his beauty still,
 Attending on his golden pilgrimage:
 But when from highmost pitch, with weary car,
 Like feeble age, he reeleth from the day,
 The eyes, 'fore duteous, now converted are
 From his low tract, and look another way:
 So thou, thyself outgoing in thy noon
 Unlooked on diest unless thou get a son.

A:

The issue lies in the fact that you're printing a list. You want to be printing elements of the list. So instead of print(s[2:16]) you can do:
for i in range(2:17):
     print(s[i])
Because the sonnets seem to be evenly spaced I would also recommend removing the ifs and making a function that returns the correct range. Looks like it's something like 2 + 14 * (sonnet_num -  1) to  2 + 14 * (sonnet_num -  1) + 14. That way you can have one if statement checking if the num is 1<=n<=7.

