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

Python Python Basics (2015) Python Data Types Use .split() and .join()

Task 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!

Can you show your code?

I don't know how to get the fancy code display, but I updated the question. Any tips would be delightful. Thank you.

9 Answers

You 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))

Excellent, it worked! Thank you for your help.

You're welcome! Happy coding!

thanks for your help ! :):) i was stuck

I think the wording of this challenge needs to be improved.

I agree with James Quirk. Very poorly worded question.

I agree with Eric and James. It is really not very clear. Wording needs an update

Neat 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)

Just got stuck in the same exercise. Really need to update the instruction.

makes it sound like an option not the actual question

Also the help from this tells u to use .join(", ") instead of ", ".join(sundaes)

wow 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)

sorry 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.'