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 trialLisa Sparks
3,187 Pointsvariable
creating variable
Lisa Sparks
3,187 PointsHaving problems with creating variable named greeting_list that's the string "Hi, I'm X" split on the spaces. I've tried greeting list=name list greeting="".join (greeting list) having a little problem completing this task.
Lisa Sparks
3,187 Pointschallenge 3, change "Treehouse" in greeting_list to the first item in your name_list variable don't know what t do.
Chris Freeman
Treehouse Moderator 68,441 PointsI've retried the challenge and I'm getting an error now as well. I'm posting my error as well and will report back.
Chris Freeman
Treehouse Moderator 68,441 PointsIn the Challenge Step 3, greeting_list
starts as an array of items with "Treehouse" as the last item. To replace the "Treehouse"in the list with the first item in name_list
you can reference "Treehouse" using greeting_list[2]
and the first item using name_list[0]
.
The assignment is straight-forward:
greeting_list[2] = name_list[0]
Alternatively, since "Treehouse" is the last item, you can use greeting_list[-1]
2 Answers
Chris Freeman
Treehouse Moderator 68,441 PointsThe question is asking to split()
the string into pieces using the "space" character as the division points and assign the resulting list to a variable named greeting_list.
The string methonsplit()
will divide a string based on any substring. The substring used is not included in the results. By default, split()
will use a "space" character. To split the string append the split()
method to the string:
"Hi, I'm X".split()
Assigning this to greeting_list
:
greeting_list = "Hi, I'm X".split()
Lisa Sparks
3,187 PointsThanks Chris Freeman
Lisa Sparks
3,187 Pointsok Ill check back with you
Chris Shaw
26,676 PointsChris Shaw
26,676 PointsHi Lisa,
Which task/part are you having trouble with?