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 trialNyasha Chawanda
7,946 PointsCreate a variable named greeting_list that's the string "Hi, I'm Treehouse" split on the spaces.
Create a variable named greeting_list that's the string "Hi, I'm Treehouse" split on the spaces.
full_name="nyasha chawanda"
name_list=full_name.split()
greeting_list="Hi,i'm Treehouse".split()
4 Answers
Manuel Tarazona
5,282 PointsYour code isn't working because you are calling split without specifying where it should be split. The split method should always be called on the string you want to split with where you want the the string to be split in between the brackets in string form. In this case, your code should be:
full_name="nyasha chawanda"
name_list=full_name.split(" ")
greeting_list="Hi,i'm Treehouse".split(" ")
It was missing the " " between the brackets in the split method.
Kenneth Love
Treehouse Guest TeacherSpacing and capitalization is important. Your greeting_list
string should be "Hi, I'm Treehouse"
with capital letters on each word and a space after the comma. Yes, it's picky. So is programming :)
Christian Linnerud
7,312 PointsLike this:
greeting_list="Hi, I'm Treehouse".split()
yunanhe
Courses Plus Student 706 Pointsgreeting_list = "Hi, I'm Treehouse".split()
Kenneth Love
Treehouse Guest TeacherKenneth Love
Treehouse Guest Teacher"Hello there".split()
and"Hello there".split(" ")
will produce exactly the same output..split()
, with no arguments, splits on whitespace (spaces, tabs, new lines).