Blenderinho
Blenderinho

Reputation: 103

Unable To Remove Whitespace On String Using Python

I'm trying to get rid of the whitespace on this list however I am unable to. Anyone know where I am going wrong with my code?

 love_maybe_lines = ['Always    ', '     in the middle of our bloodiest battles  ', 'you lay down your arms', '           like flowering mines    ', '   to conquer me home.    ']
    
    love_maybe_lines_joined = '\n'.join(love_maybe_lines)
    love_maybe_lines_stripped = love_maybe_lines_joined.strip()
    print(love_maybe_lines_stripped)

Terminal: 

Always    
     in the middle of our bloodiest battles  
you lay down your arms
           like flowering mines    
   to conquer me home.

Upvotes: 0

Views: 99

Answers (1)

Synthaze
Synthaze

Reputation: 6080

love_maybe_lines = ['Always    ', '     in the middle of our bloodiest battles  ', 'you lay down your arms', '           like flowering mines    ', '   to conquer me home.    ']

love_maybe_lines = [item.strip() for item in love_maybe_lines]

That may help.

Upvotes: 2

Related Questions