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 trial
Gavin Hughes
6,487 PointsUse .split() and .join()
Hi. Just revisiting some Python exercises that I completed a while back as a refresher and I cant get part 3 of this challenge to pass. I've tried running this in my python shell in terminal and seems that somewhere along the line I'm not creating a string where I should be as update seems to be a list? Not sure what I'm missing.
available = "banana split;hot fudge;cherry;malted;black and white"
sundaes = available.split(";")
menu = "Our available flavors are: {}.".format(sundaes)
update = ', '.join(sundaes)
menu = menu.format(update)
4 Answers
jacinator
11,936 PointsVery close. This should work.
available = "banana split;hot fudge;cherry;malted;black and white"
sundaes = available.split(";")
menu = "Our available flavors are: {}." # Remove formatting...
update = ', '.join(sundaes)
menu = menu.format(update) # ...so that you can format it here.
Gavin Hughes
6,487 PointsAh, oops! Thank you.
dmitriy ignatiev
Python Web Development Techdegree Student 1,789 PointsHi, everyone
Could you please clarify what wrong with my code below. I don't understand why it is failed in task and i can't go further. I checked my code in shell and it's work perfectly.
available = "banana split;hot fudge;cherry;malted;black and white" sundaes = available.split(";") menu = "Our available flavors are: {}." final_menu = menu.format(",".join(sundaes))
Jeff Muday
Treehouse Moderator 28,732 PointsDmitriy, Your code is indeed correctly formatted (and runs on my python shell). The only change that might make it pass the code challenge is to change the "join" to include a space after the comment -- see below.
final_menu = menu.format(", ".join(sundaes))
dmitriy ignatiev
Python Web Development Techdegree Student 1,789 PointsHi Jeff
Thank you for your help but it still error.
Didn't find the right series of sundaes and commas in menu.
Jeff Muday
Treehouse Moderator 28,732 PointsIt's been awhile since I did that code challenge. What is the step in the course for the code challenge? I would be happy to revisit that and comment further.
best, Jeff
Jeff Muday
Treehouse Moderator 28,732 PointsJeff Muday
Treehouse Moderator 28,732 PointsThe last line: menu.format(update)
Doesn't have a brace pair {}, so the update is never put in to the menu.
This might be the intended sequence of commands you were looking for: