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

Amani Alm
Amani Alm
287 Points

stuck in, Use .split() to break the available string Task

For Task # 1 in splinting and Joining, I answered the following; available = "banana split;hot fudge;cherry;malted;black and white" "banana split;hot fudge;cherry;malted;black and white" .split(";") Sundaes= ['banana split', 'hot fudge', 'cherry', 'malted', 'black and white']

I am not sure I get the question. I thought I understood "splitting & joining" but for some reason, I can't pass this task. Help please!

banana.py
available = "banana split;hot fudge;cherry;malted;black and white"
"banana split;hot fudge;cherry;malted;black and white" .split(";")
Sundaes= ['banana split', 'hot fudge', 'cherry', 'malted', 'black and white']

1 Answer

Hi there,

Use the split method using dot notation on the available list. Pass in the ';' as the argument for .split(). Assign that into sundaes.

You've got most of that in your code but you've typed a lot of sundaes which are contained in available. So use that, rather than creating new strings.

Steve.

I am completely lost on how to assign the split list to sundaes!

Hi there,

Create the variable sundaes, follow that with an equals sign and after the equals sign, call the split() method on available using dot notation and put the semicolon in the parentheses surrounded by inverted commas.

Like this:

sundaes = available.split(';')

Steve.