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

Mariya Shklyar
Mariya Shklyar
1,022 Points

Can't figure out what I did wrong on the last line

available = "banana split;hot fudge;cherry;malted;black and white" sundaes = available.split(";") menu = "Our available flavors are: {}." menu.format(", ".join(sundaes))

banana.py
available = "banana split;hot fudge;cherry;malted;black and white"
sundaes = available.split(";")
menu = "Our available flavors are: {}."
menu.format(", ".join(sundaes))

It looks good just remove "menu" from your last line and place the whole line after the third line and you should be good to go.

4 Answers

Like this:

menu = "Our available flavors are: {}.".format(", ".join(sundaes))
Mariya Shklyar
Mariya Shklyar
1,022 Points

Thank you for your suggestion, Jeremy. But I think I got confused with the Task 3 . Can you see what I did wrong on that one?

Alright, let's finish making our menu. Using whatever variable name you want (other than sundaes), 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. Oops! It looks like Task 1 is no longer passing.
banana.py

1 available = "banana split;hot fudge;cherry;malted;black and white" 2 sundaes = available.split(";") 3 ice_cream = sundaes(', ').join 4 menu = "Our available flavors are: {}.".format(ice_cream)

Task 2:

available = "banana split;hot fudge;cherry;malted;black and white"
sundaes = available.split(';')
menu = "Our available flavors are: {}."

Task 3:

menu = "Our available flavors are: {}.".format(", ".join(sundaes))

So the entire code should look like this when you are done:

available = "banana split;hot fudge;cherry;malted;black and white"
sundaes = available.split(';')
menu = "Our available flavors are: {}.".format(', '.join(sundaes))
Chancellor Griffin
Chancellor Griffin
2,212 Points

Hey Jeremy, Related to this, I had a similar issue earlier since the question was asking to make a new variable that's not named 'sundaes'. So I would make it look like:

available = "banana split;hot fudge;cherry;malted;black and white"
sundaes = available.split(';')
menu = "Our available flavors are: {}."
flavors = ', '.join(sundaes)
menu = "Our available flavors are: {}.".format(flavors)

I did it this way because the question wanted us to make a new string, i.e. 'flavors', then put it into a replacement menu, but when I did it this way it claimed I was breaking task 1. Any idea why?

I have not read the details of the challenge but I would suggest removing your third line for the last task- I don't think you need two 'menu' lines in there.

Mariya Shklyar
Mariya Shklyar
1,022 Points

I finally figure that out! available = "banana split;hot fudge;cherry;malted;black and white" sundaes = available.split(";") menu = "Our available flavors are: {}." ice_cream = ", ".join(sundaes) menu = menu.format(ice_cream)