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 trialLee Ashton
1,102 Pointssplitting and assigning strings to new variable. Help me please, was sailing along so well.
getting stuck on splitting strings and assigning them to new variable
available = "banana split;hot fudge;cherry;malted;black and white"
"sundaes: {}".format('; '.split(available))
3 Answers
Krishna Pratap Chouhan
15,203 Pointssplit() splits a string with the delimiter provided.
So,
"some; string; is; here".split(';')
will return a list containing
["some", " string", " is", " here"].
maybe you meant something like this:
available = "banana split;hot fudge;cherry;malted;black and white"
"sundaes: {}".format(available.split(';'))
Lee Ashton
1,102 PointsThanks for responding, I typed the same code as you have and it keeps telling me to try again. And I have tried various ways of typing the code different but still no joy.
Genaro Cedillo
Courses Plus Student 471 Pointssundaes = available.split(';') is the answer to this its then next part i have trouble too
Krishna Pratap Chouhan
15,203 PointsKrishna Pratap Chouhan
15,203 PointsThe answer above answers the way split() is to be used.
here is the code with explanation:
Hope this answers your query.