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

Please help...

Coding in python please look at the lesson.

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

2 Answers

Jennifer Nordell
seal-mask
STAFF
.a{fill-rule:evenodd;}techdegree
Jennifer Nordell
Treehouse Teacher

Hi Terry! You are doing brilliantly! You're even managing to complete the hard challenge ... to do it on one line. Would you believe you're off by one space? Seriously. That's it... a single space! It should be joined with a comma and a space. But you have it joined with simply a comma. Try adding a space after the comma, and your code passes with flying colors!

Well done! :thumbsup: :sparkles:

Thank you so much!! Im glad i took the time to learn this!

I'm probably wrong but you'll have to forgive me for this because you are the moderator and after going through the challenge again I see that it works, but I was following the instructions and in them it asks you to:

"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 (", ")."

After thinking about it, I believe that this is the challenge I had issues with the first time, so I did as I just did and searched the community for help on the issue. The first time I guess I just let it go cause I felt foolish for the error and for wasting so much time on the problem, but after thinking about it for a minute, I was a proofreader for a number of years and I would have flagged that very item for review..., only because it also says in the challenge that:

"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."

Which in my mind says to complete the challenge as:

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

Which is wrong and hence the reason I went to the community to research why I was wrong.

Please explain...

Jennifer Nordell
seal-mask
.a{fill-rule:evenodd;}techdegree
Jennifer Nordell
Treehouse Teacher

Brian Young Hi there! The key here is that it says to "reassign the menu variable". In your example you reassign the the display_menu variable :smiley:

Also, there's this quote:

If you're really brave, you can even accomplish this all on the same line where menu is currently being set.

Nowhere in your code is there a menu variable at all. Instead, you're setting a display_menu.

Your correct!
I took the instructions literally, and changed menu to display_menu which is the only reason I had trouble with the code. ;-) Once I removed the 'display_' it passed...

Yes, once I saw the correct answer, I thought; "I could have had a V8!" Thank you for your assistance.