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

split, join

Here's my attempt but it's not working. I saw the post from Luis Wanus (I hope I his name right). I tried a few variations for what he had but none of them worked for me.

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

Here are the instructions given.

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.

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

5 Answers

Antonio De Rose
Antonio De Rose
20,884 Points
available = "banana split;hot fudge;cherry;malted;black and white"
sundaes=available.split(';')
menu="Our available flavors are: {} "
display_menu=menu #what are you trying to do here, this is not what is been asked

menu="Our available flavors are: {} ".format(display_menu)(", ".join(sundaes))
#you are trying to format, something, which is of not requested
#you have progressed well, I'd say comment out display_menu = menu
#then do not use, display_menu, when formatting, instead, format what is been asked (", ".join(sundaes))

#let me know, how you go with it.

Well, on the instructions, it says to combine the sundaes list into a new variable named display_menu where each item is rejoined together by a comma and a space (", "). So, what I included is just one of my attempts to get the last step in this challenge to work. I had previously tried: (", ").join(sundaes), then, (", ".joint(sundaes)), then, display_menu=menu.format(display_menu)(", ".join(sundaes)) I had also tried: menu="Our available flavors are: {} ".format(display_menu)(", ").join(sundaes) I tried many other variations but I tried to follow the directions as best I could but I am still struggling to understand what is meant by some of the instructions. So, because of this, I'm sure that I'm not getting things right, quite yet.

Antonio De Rose
Antonio De Rose
20,884 Points

from what you say, I can understand, you have tried it with the right way, so we try bring it together for the 3rd step

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

# what you have done in your exercise is
#display_menu=menu --this step is wrong
#however you have mentioned, that you have tried

(", ").join(sundaes) # -- this step would be correct, if you are storing into the display_menu variable
(", ".joint(sundaes)),  # -- even, this would have been correct, if you are to store into display_menu, if not for the spelling "joint"
display_menu=menu.format(display_menu)(", ".join(sundaes))  #this line is not correct, one is you are storing into
# display_menu, the final outcome, and the other is formatting
menu="Our available flavors are: {} ".format(display_menu)(", ").join(sundaes) #this is wrong, why you have both
#display menu and the continuation

Ok, so they are all wrong. I don't know that I understand what you mean that a certain step would be correct if I was storing into the display_menu. Does that mean that, if I was going to put the menu items into a new variable named display_menu? That is what it seems like the instructions are telling me to do. Of course, since none of what I've tried has been correct that means, to me that I don't truly understand what the instructions are telling me to do. I will keep trying though because I want to understand. The joint, was a typo.

Antonio De Rose
Antonio De Rose
20,884 Points
 #ok let us bring it together, am doing the break down way.

available = "banana split;hot fudge;cherry;malted;black and white"

#your code
sundaes=available.split(';') 
menu="Our available flavors are: {} "
display_menu=menu #as I mentioned this is wrong
menu="Our available flavors are: {} ".format(display_menu)(", ".join(sundaes))

#my code
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)

#or else you could even do this way, bypassing not having anything in display_menu
available = "banana split;hot fudge;cherry;malted;black and white"
sundaes=available.split(';')
menu="Our available flavors are: {} ".format(", ".join(sundaes))

Antonio, I thank you for your help on this. I'm going to have to come back to it though. I have some pressing home work assignments due for my programming and logic class. I am going to pick this back up, as soon as I can though. So, that I can continue with my learning on treehouse. I think I am learning more through treehouse than through the college courses that I'm taking but I can't pay for degree through treehouse.