Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

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

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.

banana.py
available = "banana split;hot fudge;cherry;malted;black and white"
sundaes = available.split(";")
menu = "Our available flavors are: {}."
display_menu = sundaes.join(", ")
menu.format(display_menu)

1 Answer

Jennifer Nordell
seal-mask
STAFF
.a{fill-rule:evenodd;}techdegree
Jennifer Nordell
Treehouse Teacher

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:

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