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!

Jeffery Austin
Jeffery Austin
8,128 Points

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

Jeffery Austin
Jeffery Austin
8,128 Points

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.

Jeffery Austin
Jeffery Austin
8,128 Points

You're welcome! Happy coding!

Matias Verardo
Matias Verardo
4,371 Points

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

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

Eric Levy
Eric Levy
14,652 Points

I agree with James Quirk. Very poorly worded question.

akin kuelhanbey
akin kuelhanbey
7,474 Points

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

Mike Tribe
Mike Tribe
3,827 Points

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)

Mohd Irwan Sophan Mohd Zahir
Mohd Irwan Sophan Mohd Zahir
1,315 Points

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

Daniel Cudney
Daniel Cudney
2,005 Points

makes it sound like an option not the actual question

Daniel Cudney
Daniel Cudney
2,005 Points

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

diego cortes
diego cortes
1,421 Points

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)

diego cortes
diego cortes
1,421 Points

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