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

.split and .join challenge on 3/3 is broken:

Here's my code: menu = menu.format(" ,".join(sundaes)). Why is this causing an error?

3 Answers

Hi, I understand your are having trouble with part 3 of the challenge, here is your solution:

To get to Task 3 you should have done the following:

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

now all you need to do is add .format() at the end of the menu variable. Once you have done that, add in the sundaes list joined by ', ' and your code should look like this:

available = "banana split;hot fudge;cherry;malted;black and white"
sundaes = available.split(';')
menu = "Our available flavors are: {}.".format(', '.join(sundaes))
Chris Freeman
MOD
Chris Freeman
Treehouse Moderator 68,454 Points

Hi Arlene, in your code the issue is with the join(). You are joining with space-comma when you need to use comma-space:

menu = menu.format(", ".join(sundaes))

Hi Haider and Chris, Thanks so much for both your help. You are right Chris, my error was using the space-comma string combo instead of the comma-space. And thanks Haider for showing the full solution. This is my first question, and it's awesome to know that there are active coders out there who are helping students out. Thanks and Happy Holidays to you both.