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 trialTheodor Fahami
1,034 PointsCode challenge 1/3
I'm stuck on the first code challange.
Here is the challenge: I think it's time for a snack. Luckily I have a string full of types of ice cream sundaes. Unluckily, they're all in one string and the string has semi-colons in it too. Use .split() to break the available string apart on the semi-colons (;). Assign this to a new variable sundaes.
Here is my code
available = "banana split;hot fudge;cherry;malted;black and white".split(';')
(I added the .split(';') to the end)
When i try this code i get this: Bummer! Don't change available
.
Why do i get this messege?
2 Answers
Jennifer Nordell
Treehouse TeacherHi there! I see you understand the split()
method! However, the challenge explicitly says to create a new variable named sundaes
to hold the available
list when split at the semicolon. By adding the split directly onto the line with the available
variable, you are changing the original value held in that variable. Take a look:
available = "banana split;hot fudge;cherry;malted;black and white"
sundaes = available.split(';')
This will take the available list and split it at the semicolon and put the result into a new variable named sundaes
.
Hope this helps!
Kevin Brace
465 PointsWhile this does work, it's wasn't explained this way in the video previously, and the challenge is kind of confusing.
abdul hakkim
2,745 Pointsabdul hakkim
2,745 Pointsthank you very much it works for me!!!!!!!!!!!!
Shanna Shadoan
845 PointsShanna Shadoan
845 Pointsavailable = "banana split;hot fudge;cherry;malted;black and white" sundaes = available.split('; ')
This is my code exactly and I'm still getting the Bummer:
sundaes
doesn't have the right content. Did you use.split(";")
? message. What am I doing wrong??Jennifer Nordell
Treehouse TeacherJennifer Nordell
Treehouse TeacherShanna Shadoan Hi there! :) The code you listed here is .
split('; ')
instead of `.split(';')
. Note the extra space inside your parentheses after the semicolon where there is no space in mine. Yes, even a space can make a difference. Instead of splitting on the semicolon it's looking to split on all semicolons with a following space, but there are none.