Python Python Basics (2015) Python Data Types Use .split() and .join()

Sean Frye
Sean Frye
1,167 Points

I am so confused. I am really trying here and I just don't get it.

I am really trying here. I unfortunately with my busy schedule haven't had as much practice as I want to, but I am really trying here and I still can't figure it out. I really want to succeed. I don't understand what I am supposed to do.
available = "banana split;hot fudge;cherry;malted;black and white"
sundaes = available.split(";")
menu = "Our available flavors are: {}."
display_menu = sundaes.join(", ")

1 Answer

Jennifer Nordell
Jennifer Nordell
Treehouse Staff

Hi there, Sean! I received your request for assistance :smiley: Would it be comforting to know that you are super close on this one? There are only two tiny issues with this. First, your join is a bit backwards. The join method is used on strings. So first we have to give the string we want to join the list with, then pass in the list. In this case, we want to join that list with a comma and a space so we would write ", ".join(sundaes). This tells Python to use the string we give first (the comma and the space) to join the the list we pass in (sundaes).

Once you fix that, there will still be one error. That last line you have is taking the menu variable and then using the format method to format it with the display_menu. It sounds just like what they asked for, right? Well, yes. But the results of that are not saved anywhere. We want it to format the the menu and store the results back into menu.

So your last two lines should be:

#join the comma and space in the sundaes list
display_menu = ", ".join(sundaes)

#format the menu and store the result back in menu
menu = menu.format(display_menu)

Hope this helps and hang in there! :sparkles:

Sean Frye
Sean Frye
1,167 Points

Thank you so much! I actually didn't realize I was close to getting this one. I'm glad I wasn't that far off. Thank you! I'm going to try and free up a lot more time to study this course so I can practice and remember more and not need to ask for help so much. lol