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

Meg Cusack
Meg Cusack
11,448 Points

Final line of code (part B of task 3) does not pass

I passed task 1 and 2. Task 3 has two parts. My first part passed. My second part (line 5 below) doesn't.

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

of note is that if I change line 5 to simply menu=display_menu

it does work, but fails the code test.

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

5 Answers

Meg Cusack
Meg Cusack
11,448 Points

furkanongoren 's code was the best answer- but there isn't an option for me to choose that one as best answer?

Ben Reynolds
Ben Reynolds
35,170 Points

You can delete line 5, and update menu variable to use display_menu instead of the join statement in the format method.

Here's the gotcha: since "menu" now uses display_menu in its value, display_menu has to be declared first, so those two lines will have to swap places.

Meg Cusack
Meg Cusack
11,448 Points

Thanks, Ben and Furkanongoren. The code that Furkanongoren posted passed. It is a bit confusing to me that it doesn't do anything with display_menu in it but he obviously greatly simplified the code!

I also tried Ben's idea (I think this is what he are saying) of deleting line 5, putting in menu = display_menu on line 4 and moving my existing line 4 to line 5, but it didn't pass.

Ben Reynolds
Ben Reynolds
35,170 Points

After the menu and display_menu lines switch places, the menu line would still need to be updated to this:

menu = "Our available flavors are: {}".format(display_menu)

But in the end, I prefer the one-liner as well.