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

Margret Murphy
Margret Murphy
1,249 Points

task 3 split() and join() challenge--having difficulties with correctly formatting menu variable.

I break my previous code on this step. it all works correctly until I added line 5 in this step. I have tried various ways of formatting this to no avail.

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

2 Answers

Hi Margret

You forgot to add the placeholder. You also don't need the second line. See below

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

you could also do it in three lines of code like so

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

Thanks, for your explanation, I appreciate it!

Peter Lawless
Peter Lawless
24,404 Points

The syntax of the .join() method is backwards. It should be:

display_menu = ', '.join(sundaes)

Check out this post on StackOverflow for a more detailed explanation.

Also, your menu variable needs a designated spot to input the display_menu variable. You could use + for string concatenation or you could use curly braces to mark where the variable should be input to use the .format() method, like:

menu = 'Our available flavors are: {}'.format(display_menu)
Margret Murphy
Margret Murphy
1,249 Points

Thanks for replying to me, it's funny how once someone points something out to me I often wonder how I never noticed it in the first place, not always, but in this case, yes. Newbie mistake!