How we convert different list elements into strings?

I don’t understand the exercise . Help me to understand how we are converting list in to string.

.strip()

Here’s the code -

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

for lines in love_maybe_lines:
love_maybe_lines_stripped.append(lines.strip())
love_maybe_full = ‘\n’.join(love_maybe_lines_stripped)

print(love_maybe_full)

Could you please read this topic:

How do I format code in my posts?

and post your code with format/markup? :slight_smile: This way, the indent(ion) of your code shows on the forum, that would be really helpful

The fastest way I can think of is using join.

#Example
list1=['I ', 'like ', 'turkey ','with ','ham']
list1_joined = "".join(list1)#We want to join it on an empty string, because each of the elements already have spaces that separate them.
print(list1_joined)
#output is I like turkey with ham

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

for lines in love_maybe_lines: #you iterate through love_maybe_lines 
 love_maybe_lines_stripped.append(lines.strip())#strip off the extra whitespace for each element in love_maybe_lines and append that to love_maybe_lines_stripped
 love_maybe_full = ‘\n’.join(love_maybe_lines_stripped)#now, in the for loop, you join together whatever element is currently in love_maybe_lines_stripped with a \n, hence why when you print this the elements appear on different lines. And notice how the last element is separated by one more line? That's because if you noticed, in your original list you had a \n that you didn't remove.

 print(love_maybe_full)