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

I think it's time for a snack. Luckily I have a string full of types of ice cream sundaes

i m not able to solve this

banana.py
available = "banana split;hot fudge;cherry;malted;black and white"
sundaes = available.split(";")

1 Answer

Kent Γ…svang
Kent Γ…svang
18,823 Points

ok, so you have gotten the first task right. Next you are supposed to store a string to the variable name "menu" and include a placeholder for another string ("{}")

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

Next, you should include the list of different flavors to the placeholder, you to this with the format()-method.

Also your supposed to join the sundaes-list to a new string, separated with a comma and a space. This you do with the join()-method. Like so :

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

This challenge actually is a bit confusing since the challenge reminds you to use .join(", "), which actually is an incorrect use of the join()-method. The correct way to use it is to include the string that should be used as the joining factor at the beginning of the method.