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

Sean McKee
Sean McKee
461 Points

How do I do this?

I took a day break and have no idea how to do this? It is probably very simple so if someone could tell me that would be greatly appreciated.

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

1 Answer

Chase Marchione
Chase Marchione
155,055 Points

Hi Sean,

  • The error message asks us if we used .join. Looking at the task 3 instructions, it seems that the challenge wants us to create a new string when doing this. This will combine the sundaes list into a string, and join the sundaes with a comma and a space, for the sake of good formatting.

  • We'll then format our freshly created string onto the menu variable, and store that as the new value of menu.

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

Hope this helps!