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 trialak37
2,344 PointsSplit and Join Excercise
I need help with this exercise. I am stumped as to what the mistake is
available = "banana split;hot fudge;cherry;malted;black and white"
sundaes = available.split(';')
menu = "Our available flavors are: {}."
display_menu = sundaes.join(", ")
menu = menu.format(display_menu)
2 Answers
Josh Keenan
20,315 Pointsavailable = "banana split;hot fudge;cherry;malted;black and white"
sundaes = available.split(";")
menu = "Our available flavors are: {}.".format(", ".join(sundaes))
display_menu = (", ").join(menu)
Here's my solution, a lot of people get stuck on this so don't worry, you have to call .join() on a string and give it the thing you want to manipulate as a parameter, so this is how you do it!
Igor Ević
5,827 PointsYour code passes fine because only menu variable is checked. What's value of your display_menu variable?
Josh Keenan
20,315 Pointsoh yeah my bad I didn't realise I did it in one line xD, did it automatically and then did the other bit for the asker
Igor Ević
5,827 PointsIgor Ević
5,827 Pointsdisplay_menu = (", ").join(menu)
is wrong. You don't need display_menu variable because you have value for menu variable in one row. But if you use display_menu, then you have:
Josh Keenan
20,315 PointsJosh Keenan
20,315 PointsYou can do it in one line yes, but when someone is learning it is better that they see it more clearly and understand everything first, before going to the best solutions. Also my code passes fine it doesn't have to be as you have it