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

I hate Tree House

:( :( :( :(

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

That's mean...

Steven Parker
Steven Parker
231,269 Points

Scott, I sympathize. You tripped over one of the rare bugs in the courses, but on the good side, Treehouse responded immediately and revised the challenge.

1 Answer

Kenneth Love
STAFF
Kenneth Love
Treehouse Guest Teacher

Hey Scott,

Sorry you're frustrated on this one. Let's see if we can get you through it. The first two lines, mine and yours, are exactly right. Your sundaes variable is now a list of different sundae types.

Your display_menu line is almost right, too. You need to join the list with a comma and a space. And you use .join() on a string, not a list. I know, I know, it seems backwards.

But that menu line is giving you trouble, huh? Right now you're sticking the list into that spot. Here's what that does:

>>> my_list = ["a", "b", "c"]
>>> "Here's my list: {}".format(my_list)
Here's my list: ['a', 'b', 'c']

Well, we definitely don't want those quote marks or brackets in there! display_menu has the data that we need in the menu, so we need to use it instead of sundaes. You could swap the order of display_menu and menu (and, of course, change what you're using in .format()) or you could reassign menu with menu = menu.format() and then the right thing inside of .format().

You can do it!

Steven Parker
Steven Parker
231,269 Points

Kenneth Love, in fairness to Scott, earlier today the instructions said, "Then use .format() on our existing menu variable to replace the placeholder with the new string in display_menu." which implies the result should go to display_menu.

Now they have been revised to read, "Then reassign the menu variable to use the existing variable and .format() to replace the placeholder with the new string in display_menu.", which is way better but still a bit awkward regarding how the use of display_menu is actually optional "if you're really brave" :wink: