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 trialLuke Eichentel
1,011 PointsWhat am I doing wrong?
Some syntax element must be violated here because this is plain cryptic. Bummer Didn't find the proper placement of commas and sundaes in menu! is what error message I am receiving. I am lost for words beyond this point, I don't want to confuse you, but I have done a fair amount of research (at least an hour and a half), asking every question that came to my mind, and used every order of logic that I could.
available = "banana split;hot fudge;cherry;malted;black and white"
sundaes = available.split(";")
menu = "Our available flavors are: {0}."
display_menu = ", ".join(sundaes)
menu.format(display_menu)
1 Answer
andren
28,558 PointsThe problem (and to be fair the challenge text does not make this super clear) is that you are supposed to replace the contents of the menu variable with the formatted version of the menu.
Like this:
available = "banana split;hot fudge;cherry;malted;black and white"
sundaes = available.split(";")
menu = "Our available flavors are: {0}."
display_menu = ", ".join(sundaes)
menu = menu.format(display_menu)
Using "menu.format(display_menu)" on it's own like you are doing in your example will just produce a formatted menu, and then essentially throw it away since you never do anything with it.
As the challenge text mention this task can also be done in a more concise manner, by placing the format call and join statement on the same line that the menu variable is declared like this:
available = "banana split;hot fudge;cherry;malted;black and white"
sundaes = available.split(";")
menu = "Our available flavors are: {0}.".format(", ".join(sundaes))
That is both shorter and requires less variables, but both methods work.
Luke Eichentel
1,011 PointsLuke Eichentel
1,011 PointsOne quickie question I want to ask "menu = menu.form..." is that essentially saying "we are declaring a new variable that will be using the old variable (of the same name) to be form...."
Luke Eichentel
1,011 PointsLuke Eichentel
1,011 PointsAlso, give an explanation for your concise menu line. In particular, my best order of logic for the placeholder is to immediately place sundaes after it. However, sundaes does need to be joined together, and learning how to do many things in one line is great for learning syntax and communicating it to others. If you can, place a lot of emphasis on what is being manipulated and what is to be manipulated, etc. Be, be, be.