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 trialtalib faridy
299 Pointshelp me in Challenge task 3 of 3. please fix some bugs also.
available = "banana split;hot fudge;cherry;malted;black and white" sundaes = available.join(";") display_menu = sundaes menu = "Our available flavors are: {}".format(", ".join(display_menu))
print(display_menu) print(menu)
available = "banana split;hot fudge;cherry;malted;black and white"
sundaes = available.join(";")
display_menu = sundaes
menu = "Our available flavors are: {}".format(", ".join(available))
print(display_menu)
print(menu)
2 Answers
Jason Anders
Treehouse Moderator 145,860 PointsHey Talib,
You are very close, but there are a few things.
- First, when creating the variable
sundaes
, you want to use.split
not.join
. - Second, you have a few things that the challenge did not ask for. Challenges are very specific and picky, so if you add things that aren't specified in the instructions, it will often throw the Bummer. You will need to delete the
display_menu
assignment (this wasn't asked for) and the twoprint
statements (also not asked for). - Finally, in the string output, you want to
.join
what's in thesundaes
variable (the value is the split of theavailable
variable.
Because you were so close, I've posted the corrected code below for you to have a look at. Everything should make sense. :)
available = "banana split;hot fudge;cherry;malted;black and white"
sundaes = available.split(";")
menu = "Our available flavors are: {}".format(", ".join(sundaes))
Keep Coding!
Thomas Spear
1,149 PointsI was also having trouble with the third part of this challenge. The question asks for a new variable named display_menu.
"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 use .format() on our existing menu variable to replace the 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."
No matter what I tried with display_menu, I could not get it to work for me. I ended up having to eliminate the display_menu part and the combination of the sundaes, and use the code suggested above. I was trying something similar to what was suggested as the answer, but using display_menu = menu.format(", ".join(sundaes)).
peterpyne
10,932 Pointspeterpyne
10,932 PointsJason, in your comment you've said
Though the challenge says:
Are there two correct ways to complete this challenge then? I understand that your answer will be the most efficient way of doing things, but just for kicks, what's the other way?
Thanks.
Jason Anders
Treehouse Moderator 145,860 PointsJason Anders
Treehouse Moderator 145,860 PointsYes, Peter Pyne, this particular challenge actually has two way to complete it. The first one is using the
display_menu
variable like so:When I originally answered the question, I guess I skimmed the instructions too quickly and went right over the 1st way and focused on the
which would only use the
menu
variable (Code for this 2nd way is above). So, for the second way,display_menu
is not needed or asked for, but you are correct in that it is needed for the 1st way (that was and oversight on my part).Hope this clears it up for you :)
Keep Coding!