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 dont understand what do i have to do?

i have no idea of how to make this challenge

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

3 Answers

Steven Parker
Steven Parker
231,248 Points

If you're totally lost, you might want to re-watch the Splitting and Joining video.

Watch for examples in the video that handle situations very similar to the one in this challenge.

i have seen the video 4 times, but in this excersice i dont know what to do ?

Cindy Lea
PLUS
Cindy Lea
Courses Plus Student 6,497 Points

This what theyre asking for:

Use .split() to break the available string apart on the semi-colons (;). Assign this to a new variable sundaes.

First, I would research the split() function & how it works. Then you have to add the symbol into the split function that will sperate the string & put this value into a variable called sundaes.

Alex Trost
Alex Trost
6,270 Points

Right, what Cindy and Steven are saying is right.

You're given this un-python friendly list, where it's one long string. We want to break it up into smaller list items so that we can use it easier. Currently, it's not so easy to work with the list and say, give the user the third sundae that we sell, or alphabetize them.

Instead of

available = "banana split;hot fudge;cherry;malted;black and white"

We'd like it to look like:

available=["banana split", "hot fudge", "cherry", "malted", "black and white"]

Because that's a python list of 5 strings.

So we want to use the handy split() function that allows you to do just that, and we want to tell the split function to split our original long string into smaller strings every time it finds a ";". So split() will search through and do just that every time it hits ";".