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

Need help understanding the question.

I just do not understand what the question is looking for.

I split available.

I created menu by using string formatting and the sundaes list.

I can create the display_menu variable by rejoining sundaes with commas.

I tried reassigning the variable menu on a seperate line and inline. Still not passing.

What part of this questions am I not understanding?

Thanks

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

Figured it out. I was using join wrong. I wish the challenges would respond with proper Python error messages. It would make tracking this stuff down much easier.

I'd suggest you use an online ide like this so you'll clearly see error messages and can easily print() things.

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

1 Answer

the join method is called on the delimiter string, with the collection as argument, so you have it backwards there.

(', ').join(sundaes)

is how you use it. you only need to use join once, to create a string of flavors, then that string becomes the argument for the format method called to form the menu string.

Thanks, James! I got Javascript Array.join() confused with Python join().