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

Alright, let's finish making our menu. Combine the sundaes list into a new string, joining them with a comma and a spac

need help...thanks in advance

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

3 Answers

Steven Parker
Steven Parker
231,271 Points

It looks like you've already completed tasks 1 and 2 — good job so far!

Now you may want to review the Splitting and Joining video. There's a good example of what needs to be done for task 3 starting at time index 4:50.

I'll bet you can figure it out without an explicit spoiler.

Drew Butcher
Drew Butcher
33,160 Points

I think you are looking for this:

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

Good code to know actually, I did something similar to this in a web application last week.

Steven Parker
Steven Parker
231,271 Points

Give a man a fish and you feed him for a day; teach a man to fish and you feed him for a lifetime.
    ― Maimonides

Thomas Helms
Thomas Helms
16,816 Points

I think the issue comes from the wording of the directions. It makes it sound like we are actually doing two/three steps:

  1. Combine sundaes into a new string
  2. Do menu.format()
  3. menu=menu.format()

It could probably changed from: 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.

To: In the menu line, use .format() and .join() to make the sundaes list into a string, with a comma and a space (", ") as separators.

Still a little awkward, but you get the idea.

Steven Parker
Steven Parker
231,271 Points

It can be done as three things. But it can also be abbreviated as you suggest (and as shown in the video).