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 trialSimon Gogwe
3,648 Pointsusing the .split() function
i have used the split function on this string but i dont know where i am missing it. The code in the way we suppose to .split() is no running. please help.
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".split(';')
3 Answers
Kevin Brennan
19,920 PointsHi Simon,
The challenge asks for you to assign the result of using split on available to sundaes. The variable available has already been declared so you just need use the split function on it and assign that to the sundaes variable.
available = "banana split;hot fudge;cherry;malted;black and white"
sundaes = available.split(';')
I hope that helps and is clear.
Kevin
Simon Gogwe
3,648 Pointsthanks Kevin. it di, now stuck on the last challenge
Kevin Brennan
19,920 PointsHi Simon,
There are two ways to accomplish the last challenge, I will show you both although the second way would be best.
Firstly you could declare the variable display_menu and use the join method on sundaes to assign to it. Then use format to put display menu into the menu string as so:
available = "banana split;hot fudge;cherry;malted;black and white"
sundaes = available.split(';')
display_menu = ", ".join(sundaes)
menu = "Our available flavors are: {}.".format(display_menu)
Or as the challenge said do it all on one line, for this you don't even bother with the display_menu variable but put the join straight into the format as so:
available = "banana split;hot fudge;cherry;malted;black and white"
sundaes = available.split(';')
menu = "Our available flavors are: {}.".format( ", ".join(sundaes))
Obviously the second way is shorter with cleaner code. I recommend playing around with the split and join functions to make sure you fully understand them before continuing.
Kevin