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 trialShea Taylor
Courses Plus Student 664 PointsPython: How do you use a string to create a list by splitting on the spaces? (this quiz Q makes no since to me).
The task at hand asked: Create a variable named greeting_list that uses the string "Hi, I'm Treehouse" to create a list by splitting on the spaces.
I'm not sure what this question is asking me to do. Is anyone able to clarify?
full_name = ("Shea Taylor")
name_list = full_name.split()
greeting_list = ("Hi, I'm Treehouse")
greeting_list.split()
1 Answer
Clayton Perszyk
Treehouse Moderator 48,850 PointsSplit will take the string it's being called on and return it as a list; so, full_name.split() returns ["Shea", "Taylor"], which is a two item list. greeting_list.split() will return a three item list, ["Hi,", "I,m", "Treehouse"]. If you call split directly on the string, "Hi, I'm Treehouse", it will return a list and assign it to the greeting_list variable.
Shea Taylor
Courses Plus Student 664 PointsShea Taylor
Courses Plus Student 664 PointsThank you for the speedy answer, Clayton! Your clarification helped me track down my mistake – I had a misplaced space in the code that kept throwing it back as incorrect. Very frustrating. All is good in the world again.
Cheers!!