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

How do i split this on the (;)

How do i make a new one for this?

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

2 Answers

Manish Giri
Manish Giri
16,266 Points

You just pass whatever you want to split on, into the .split() function. In this case, you pass ;, like .split(";").

Tony Castro
Tony Castro
266 Points

I'm also a little stuck on this. I do the .split(";") but I still get it wrong/bummer. I think I'm messing up on the part where I have to assign it to a new variable. Any tips would be great.

Manish Giri
Manish Giri
16,266 Points

Can't say what's wrong without seeing your code, but the general way is this -

sentence = "Hello World"
words = sentence.split(" ")

Now, words is a list that looks like ['hello', 'world'].

Tony Castro
Tony Castro
266 Points

ok, now I see where I went wrong. I was doing, words=sentence I didn't add the .split(";") on the new line. THANK YOU!!!