I'm on the String Methods review thing

Can anyone tell me what I’m doing wrong here? I’ve even looked at the solution and can’t tell what I’m doing wrong. I’m stuck here as I can’t get passed this step and move forward.

link to thing here: Lesson Review

highlighted_poems = "Afterimages:Audre Lorde:1997,  The Shadow:William Carlos Williams:1915, Ecstasy:Gabriela Mistral:1925,   Georgia Dusk:Jean Toomer:1923,   Parting Before Daybreak:An Qi:2014, The Untold Want:Walt Whitman:1871, Mr. Grumpledump's Song:Shel Silverstein:2004, Angel Sound Mexico City:Carmen Boullosa:2013, In Love:Kamala Suraiyya:1965, Dream Variations:Langston Hughes:1994, Dreamwood:Adrienne Rich:1987"

highlighted_poems_list = highlighted_poems.split(',')
highlighted_poems_stripped = []
for poem in highlighted_poems_list:

Hello, @script2197106845

Looks like maybe you used a method other than the one you intended to use in the line above.


Also, please format your code in future posts using the </> button to preserve indentation, special characters, etc. Go to a blank line, click on the </> in the menu bar, then paste your code in the space indicated. That will make your code much easier to read and run for those wishing to assist you.

1 Like

but the solution code has the same code as mine, what was I supposed to use then? also sorry im kinda new to this I didnt know how to put it in the code, ill fix it

I haven’t looked at the exercise, but if the list is called highlighted_poems_stripped it would seem that the .strip() method should be used instead of the .split() method.


" Notice that there is inconsistent whitespace in highlighted_poems_list . Let’s clean that up.

Start by creating a new empty list, highlighted_poems_stripped .

Then, iterate through highlighted_poems_list using a for loop and for each poem strip away the whitespace and append it to your new list, highlighted_poems_stripped ."

That is what the instructions say, I need to remove the whitespace from highlighted_poems_list and append it to the empty list highlighted_poems_stripped using a for loop.

Sorry if I’m bothering you, but this literally just makes no sense since its not working. I know its gonna be something very small and obvious that I’m doing wrong.

Your code is correct except for calling the wrong method to strip the whitespace. You called the split() method instead of the strip() method. Change that, and you’ll have what you were after.
Happy coding!

P.S. Thanks for formatting your code! :+1:


Oh my god… thank you! I love you! I was literally stumped for like an hour…


Happened the exact same thing for me. Split instead of strip >(