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

In splitting and joining challenge task 3, I do not understand this: Where to get .format(sundaes.join(", ")) ?

I tried to add it directly into original menu variable, but then the task 1 is no longer passing. Thank you.

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

Where to get this?
.format(sundaes.join(", "))

2 Answers

Magali Doucet
Magali Doucet
2,330 Points

I finally did it with only one line. So I wrote: menu += ", ".join(sundaes)

and it works Good Luck

Josh Keenan
Josh Keenan
20,315 Points

This challenge isn't an easy one and a lot of people struggle with it, also the message that flashes when you get an error is misleading with the syntax when using .join().

Here's my solution to the problem, you call .join() on the string you want to use to combine something, then you pass it the thing you want to be joining together.

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

new_str = ', '.join(sundaes)
menu = menu.format(new_str)