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()

im stuck

im not getting the second step i dont even know if i got the first part right either

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

Combine the sundaes list into a new string, joining them with a comma and a space (", "). Use that string with a .format() on our existing menu variable and replace the current value of menu.

1 Answer

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

Hi there! You're actually doing really well. The second line isn't needed. Now, the trick here is that you need to use the .format to insert the thing you're trying to insert in the curly braces. Take a look at how close you are!

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

So available sundaes was given to us. Then we take that list and split it at the semicolon. This means that we'll now have a list that looks like this: "banana split hot fudge cherry malted black and white". But we want a list that looks like this: "banana split, hot fudge, cherry, malted, black and white". And we do this by taking the sundaes we just split apart and then rejoin them with a comma and a space. So we join the sundaes with a comma and a space inside the format which then sends the result into the curly braces. This will print out a nice, neat list for our users!

Hope this is helpful! :smiley:

its a lot of new info never did anything like this itll just take time but thanks it does help