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

Jason Cohen
Jason Cohen
232 Points

.split and then assign variable

Not sure what im missing here.

I split 'available' using 'available.split(;)'

I then assigned the variable 'sundaes' with = "available.split(;)"

Any ideas on what im doing wrong?

Thanks

Jason


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

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

1 Answer

Jennifer Nordell
seal-mask
STAFF
.a{fill-rule:evenodd;}techdegree
Jennifer Nordell
Treehouse Teacher

Hi there! You were really close on this one and you were definitely on track on the 3rd line. The second line you can safely remove. On the third line, you have this:

sundaes = "available.split(;)"

Remember that whatever is put inside quotation marks is a string literal. If you were to now print(sundaes) to the screen it would display "avalaible.split(;)". You have misplaced your quotation marks. The quotation marks should be around the semicolon. The semicolon is the string we want to split on. You're looking for available.split(";").

Hope this helps! :sparkles:

Jason Cohen
Jason Cohen
232 Points

Thanks Jennifer, appreciated.

A week into learning python my head is spinning, but its slowly making sense as it all comes together :-)

I got it in the end..

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