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

Jay Buakaew
Jay Buakaew
287 Points

I am not sure how to proceed

Workspace showed that I was able to split the string, but I'm not sure how to set that to the variable sundaes.

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

You are on the right way for sure but you have one mistake. Since You are making a copy of variable you don't need to set sundaes to it's content but rather it's variable name This is the right way of doing it:

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

1 Answer

Mattias Nelson
Mattias Nelson
961 Points

G'day there Jay!

The approach you are doing is correct in one way, you are indeed successfully splitting the string and assigning it to our value 'sundaes', but it's not the answer that the challenge is seeking.

To pass this first bit of the challenge, you need to split the variable 'available' to proceed to the next step.

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

sundaes = available.split(";")

I know, you're inputting the exact same string that the variable 'available' has and logically it would work. But remember, the challenges can be SUPER picky at times. It's a habit I myself am working out of, but be sure that you know each detail that the challenge is asking you and don't be afraid to re-read the demands or errors of the task at hand. There's been several times where I could've saved myself several headaches if I simply slowed down and read the demands of the challenge or the errors which the program divulged to me upon compiling.

Hope this helps ya out mate!

P.S.

Were you retyping the string which was stored within 'available' just to see if you can get the program/challenge working?

Jay Buakaew
Jay Buakaew
287 Points

Thank you. Your suggestion worked. I thought I hit a road block there, but I guess it's the first of many to come...