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 trialmarvelousstudent337
10,115 PointsTask 3 of .split() and .join() challenge
Hello everyone!
So the question was:
"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."
I'm not sure what I'm missing. I'm not sure how to combine the sundaes list into a new string without making task 1 invalid.
`
available = "banana split;hot fudge;cherry;malted;black and white"
sundaes = available.split(';')
menu = "Our available flavors are: {}."
"Our available flavors are: {}.".format(",".join(sundaes))
`
Any thoughts?
Thank you for your help!
marvelousstudent337
10,115 PointsI don't know how to get the fancy code display, but I updated the question. Any tips would be delightful. Thank you.
9 Answers
Jeffery Austin
8,128 PointsYou almost got it right, you need to change menu with your format, and you don't want to forget the space after your comma in your join statement.
available = "banana split;hot fudge;cherry;malted;black and white"
sundaes = available.split(";")
menu = "Our available flavors are: {}.".format(", ".join(sundaes))
marvelousstudent337
10,115 PointsExcellent, it worked! Thank you for your help.
Jeffery Austin
8,128 PointsYou're welcome! Happy coding!
Matias Verardo
4,371 Pointsthanks for your help ! :):) i was stuck
James Quirk
1,110 PointsI think the wording of this challenge needs to be improved.
Eric Levy
14,652 PointsI agree with James Quirk. Very poorly worded question.
akin kuelhanbey
7,474 PointsI agree with Eric and James. It is really not very clear. Wording needs an update
Mike Tribe
3,827 PointsNeat answer.
I did it step by step at first, which worked fine in IDLE but not in "Workspace"
available = "banana split;hot fudge;cherry;malted;black and white" sundaes = available.split(";") menu = "Our available flavors are: {}." sundaes = ", ".join(sundaes) menu = menu.format(sundaes) print(menu)
Mohd Irwan Sophan Mohd Zahir
1,315 PointsJust got stuck in the same exercise. Really need to update the instruction.
Daniel Cudney
2,005 Pointsmakes it sound like an option not the actual question
Daniel Cudney
2,005 PointsAlso the help from this tells u to use .join(", ") instead of ", ".join(sundaes)
diego cortes
1,421 Pointswow the wording of this question is misleading, i solved in the IDLE and it worked i also included the variable display_menu, but when i submitted the answer it wouldnt pass, so i submitted Jeffrey Austins answer and it worked, thank you i had been stuck in this problem for a while. this was my answer display_menu = ', '.join(sundaes) menu.format(display_menu)
diego cortes
1,421 Pointssorry i posted the wrong solution i came up with, this is the one i used on the idle: available = 'banana split;hot fudge;cherry;berry;strawberry and vanilla'
sundaes = available.split(';') menu = 'our available flavors are:{}.' display_menu = ', '.join(sundaes) menu = menu.format(display_menu) menu 'our available flavors are:banana split, hot fudge, cherry, berry, strawberry and vanilla.'
Jeffery Austin
8,128 PointsJeffery Austin
8,128 PointsCan you show your code?