How to add strings to a list?

No, you just need a list to give it as an argument, and a separator string for between the entries.

" ".join(a_list)

3 posts were split to a new topic: Difference between defining a function and simply writing a for loop

I wrote the exact same code and had the same question.

Would it be easier to use list comprehensions?

love_maybe_lines_stripped = [line.strip() for line in love_maybe_lines]

1 Like

Only if the concept has already been introduced. We do not want to race ahead else run the risk of missing important details in the naive approaches. Work with what you’ve been taught to this point.

good day. Please is this 4 arguments? i.e. are the arguments (’: ! . '). What I’m asking is if one of the arguments is a white space? Thank you. I’m sorry i know I ask way too many questions. I’m just totally new to coding

1 Like

Technically it is one argument, a single string. However, you are correct in assessing it as four separate values, space included, all of which are independently applied by the .strip() method.

1 Like

Thank you very much for clearing that up.

1 Like

That’s what I used. I am taking the course here in early 2021, and they way they have it formatted now is that you learn list comprehensions before string methods.

If that is actually the case, then this needs to be corrected.