.strip() How to remove '' space


I can’t figure out something related to one of the practice lessons. (https://www.codecademy.com/courses/learn-python-3/lessons/string-methods/exercises/strip)

I managed to get the correct result codeacademy wanted me too but i can’t figure out how to fix this:

love_maybe_lines_stripped = []

for line in love_maybe_lines:

love_maybe_full = '\n'.join(love_maybe_lines_stripped)

It returns an empty space between the last two lines as a ’ ’ in the list. How do i remove that empty space?

There are five string given in list, even if you remove every character in the string you’d still have an empty string which is perfectly valid, e.g. text = "". When you join them back up your final string looks like- 'Always\nin the middle of our bloodiest battles\nyou lay down your arms\nlike flowering mines\n\nto conquer me home.' (note the repeated newline \n\n).

I’m pretty sure that’s intentional in this example and that would be the formatting of the original poem.

In terms of code you’d probably want to either remove the empty string from the list before joining them back up or work on the created string after joining them up.

Yeah that’s what i’m asking. After joinin them in a format(\n)

I get an empty line of code. How to bypass that

There’s a couple of options in that reply-