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

Jade Sholty
Jade Sholty
3,036 Points

The wording on this question is confusing and I am unsure what you want us to do

Confused by part 2 of this question. Not sure what the outcome is supposed to be:

"Then reassign the menu variable to use the existing variable and .format() to replace the placeholder with the new string in display_menu. If you're really brave, you can even accomplish this all on the same line where menu is currently being set."

Currently I had:

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

but I am not sure what you are asking for in part 2 when you say "reassign the menu variable to use the existing variable and .format() to replace the placeholder" etc. It's a little confusing what the goal is here.

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

2 Answers

Jade Sholty
Jade Sholty
3,036 Points

Thanks, I finally figured out what they wanted (by trial and error). I just wasn't sure what they wanted the final sentence to read based on the way the question was worded. Thanks again for sending over that info. Thanks also for sending over the second shortened version. Helps to see the simplified version as well. Have a great night :)

Dmitriy Ignatiev
PLUS
Dmitriy Ignatiev
Courses Plus Student 6,236 Points

Hi Jade,

The menu should be(if you print it out):

Our available flavors are: banana split, hot fudge, cherry, malted, black and white.

But in your code it will be:

Our available flavors are: b, a, n, a, n, a, , s, p, l, i, t, ,, , h, o, t, , f, u, d, g, e,

It is because in last string of your code you use ",". join function again which takes each letter within display_menu. You need use just format and exclude join.

menu = menu.format((display_menu))

It will works well