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 trialOmkar Palekar
3,503 Pointscode challenge 3/3
Alright, let's finish making our menu. Using whatever variable name you want (other than sundaes), combine the sundaes list into a new string, joining them with a comma and a space (", "). Use that string with a .format() on our existing menu variable and replace the current value of menu.
and this what i have done
available = "banana split;hot fudge;cherry;malted;black and white" sundaes = available.split(";") menu = "Our available flavors are: {}." menu.format(", ".join(sundaes))
6 Answers
andren
28,558 PointsThe code is mostly correct, you are just missing one step of the challenge:
"Use that string with a .format() on our existing menu variable and replace the current value of menu."
You are formatting the menu variable in the right way but you aren't storing that formatted menu anywhere, you are just formatting it and then doing nothing with the result of that.
If you change the last line of your code to this:
menu = menu.format(", ".join(sundaes))
Then you should be able to pass the challenge.
Jeffrey Lee
493 PointsThis is able to get you to pass the challenge too
Special = "Our available flavors are: {}.".format(", ".join(sundaes))
Sky Lu
1,260 PointsHi Andren, I've tried menu = menu.format(", ".join(sundaes)), it doesn't work, it looks your code is make sense too. below code made passed the Task 3:
menu = 'Our available flavors are: {}'.format(', '.join(sundaes))
Nichole "Nikki" Carnesi
7,103 PointsI'm working on this one right now. I got the first two challenges correct but the third one is perplexing me. After reading through this thread, I wonder if the question has changed from 4 months ago because I'm not relating.
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 (", "). 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.
What I know I got right:
available = "banana split;hot fudge;cherry;malted;black and white"
sundaes = available.split(";")
menu = "Our available flavors are: {}."
What I can't seem to figure out:
display_menu = menu.format(", ".join(sundaes))
What am I doing wrong or missing?
EDIT: I changed my answer to:
menu = "Our available flavors are {}.".format(", ".join(sundaes))
I think what really threw me off is the wording of the challenge and putting display_menu in italics made me think I was suppose to use that as my variable, at least that is how I read it.
andren
28,558 PointsNichole "Nikki" Carnesi: You are far from the only person that have been thrown off by that, in fact I think this might be the most common misunderstanding on this forum. There are often multiple posts per day of people that tend to be confused about that exact thing.
The display_menu
bit in the instructions is a reference to the fact that there are two official ways of solving this challenge. The first does involve using a variable with the name display_menu
, but the second shorter solution (which you found) does not involve using it.
The longer solution 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)
And does the same thing as the shorter solution, it just breaks it into more discreet steps.
I do agree that the instructions as written is not very clear, though it's worth noting that you are correct about the question. It was in fact rewritten at some point due to confusion, but evidently they didn't do a great job with the new instructions either. And the actual challenge did not change, just the wording of the task.
Balazs Kelemen
8,948 PointsThis is what I did. For some reason none of the above worked for me :(
available = "banana split;hot fudge;cherry;malted;black and white"
sundaes = available.split(";")
menu = "Our available flavors are: {}.".format("; ".join(available))
special = ", ".join(sundaes)
menu = "Our available flavors are: {}.".format(special)
Sky Lu
1,260 Pointsmenu = "Our available flavors are: {}.".format("; ".join(available)) this is wrong man, Method:Join is making a list to string. Available is a string, not a list. A list is using [ ] to present.
The answer for Task 2: one should be: menu = 'Our available flavors are: {}.'.format(sundaes)
The answer for Task 3: menu = 'Our available flavors are: {}'.format(', '.join(sundaes))
Sky Lu
1,260 PointsHi guys, The question of Task 3 mentioned " Using whatever variable name you want (other than sundaes), " From my opinion, I can use any words for the variable, for instance, I used below code, the system didn't let me pass the task: abc = 'Our available flavors are: {}'.format(', '.join(sundaes))
if I change the variable from "abc" to "menu" which as below, I passed the task. menu = 'Our available flavors are: {}'.format(', '.join(sundaes))
I thought I got wrong thoughts about " Using whatever variable name you want (other than sundaes), ", right?
Nichole "Nikki" Carnesi
7,103 PointsAndren, thank you for your feedback. I appreciate knowing I wasn't the only one thrown off. I think I was also trying to do the longer version but couldn't quite get it to work.
Thanks again.
abdul hakkim
2,745 Pointsthanks for all who ask question and who answered!!!!!!!!!!!!!
Jeffrey Lee
493 PointsJeffrey Lee
493 PointsYou can use header in markdown to make your post clearer:)
https://github.com/adam-p/markdown-here/wiki/Markdown-Cheatsheet