Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

Python Python Basics (2015) Python Data Types Use .split() and .join()

Larry Tooley
Larry Tooley
23,518 Points

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(', ')
Larry Tooley
Larry Tooley
23,518 Points

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.

Tri Pham
Tri Pham
18,671 Points

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

Anani Assoutovi
Anani Assoutovi
Courses Plus Student 1,048 Points

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

james south
seal-mask
.a{fill-rule:evenodd;}techdegree seal-36
james south
Front End Web Development Techdegree Graduate 33,258 Points

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.

Larry Tooley
Larry Tooley
23,518 Points

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