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 trialilya A
3,802 PointsWhat am I doing wrong?
I am not exactly sure how to reassign my menu variable.
available = "banana split;hot fudge;cherry;malted;black and white"
sundaes = available.split(';')
menu = "our available flavors are: {}.".format("sundaes")
display_menu = sundaes.join(", ")
3 Answers
ilya A
3,802 PointsThank you. I was also wondering how the problem could be solved without adding an extra line of code, I got this far:
available = "banana split;hot fudge;cherry;malted;black and white"
sundaes = available.split(';')
menu = "Our available flavors are: {}.".format(display_menu = ", ".join(sundaes))
I am currently getting an error...
Chris Freeman
Treehouse Moderator 68,441 PointsYou are close! Two items to fix:
the join
is a string method, so it is called on the "glue string" used to join the item in the listed argument.
', '.join(sundaes)
The format needs to use the display_menu
and not the sundaes
list.
ilya A
3,802 Pointsavailable = "banana split;hot fudge;cherry;malted;black and white"
sundaes = available.split(';')
menu = "our available flavors are: {}.".format("display_menu")
display_menu = ", ".join("sundaes")
I tried this, but I am getting an error: Bummer! Did you use ", ".join()
?
[MOD: added ```python formatting -cf]
Chris Freeman
Treehouse Moderator 68,441 PointsYou are much closer. The arguments to join and format should not be in quote because they are variable names. By using quotes they are seems as simple strings.
Removing the quotes causes a new problem: display_menu
is referenced before it is assigned. Swap the last two lines so display_menu
is defined before it is used in the format method.
Chris Freeman
Treehouse Moderator 68,441 PointsChris Freeman
Treehouse Moderator 68,441 PointsThe failure is caused by using an assignment statement in the format arguments.
Remove the assignment and it will pass. Explicitly assigning display_menu is not required to pass the challenge:
ilya A
3,802 Pointsilya A
3,802 PointsThank you!