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 trialRatheesh Mukundan
2,140 PointsCreate a variable named greeting_list that uses the string "Hi, I'm Treehouse" to create a list by splitting on the spac
please help me to solve this question...
2 Answers
Chris Freeman
Treehouse Moderator 68,441 PointsWhen a string literal is created it has all of the methods and attributes of other strings so you can use the .split()
method directly. No argument to split()
is necessary because "on spaces" is the default.
# Task 2 of 4
# Create a variable named 'greeting_list' that uses the string
# "Hi, I'm Treehouse" to create a list by splitting on the spaces.
greeting_list = "Hi, I'm Treehouse".split()
luis Cabrera
802 PointsYou need to split on the spaces. Use split(" ")
Chris Freeman
Treehouse Moderator 68,441 PointsCorrect. Note that splitting on whitespace is the default action if non sep
separation argument is given. (docs)
Josh Taylor
1,239 PointsJosh Taylor
1,239 PointsWhen I use this code, it returns
"Bummer! Your greeting_list doesn't have the right content. Did you split the string "Hi, I'm Treehouse"?"
Chris Freeman
Treehouse Moderator 68,441 PointsChris Freeman
Treehouse Moderator 68,441 PointsJosh. Can you post exactly the code you've used for task 1 and 2?