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 am new to python and coding as a whole, and I am a bit confused on what the question is asking of me.

the question is not clear to me on how I can rejoin by a comma and space, could someone help explain it to me? thank you!

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

here is the question

Challenge Task 3 of 3

Alright, let's finish making our menu. Combine the sundaes list into a new variable named display_menu, where each item in the list is rejoined together by a comma and a space (", ").

Then reassign the menu variable to use the existing variable and .format() to replace the placeholder with the new string in display_menu.

1 Answer

andren
andren
28,558 Points

This challenge is somewhat infamous for confusing quite a large amount of users so you don't need to feel too bad about being confused by the instructions.

This challenge actually has two different intended solutions, one which requires using the display_menu and one which doesn't, your code is actually very close to the solution that does not require the display_menu variable.

The only issue with your code is that you are joining the sundaes variable on a period and a space ". " rather than a comma and a space ", ".

If you change that and remove the display_menu variable like this:

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

Then your code will pass.

The other intended solution for this challenge looks like this:

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

That solution performs the same work as the other solution but splits the joining of the sundaes and the formatting of the menu into separate steps.

Thank you so much. This was a big help and made the question clear for me. That is so awesome!