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 trialDan Andresen
Courses Plus Student 636 PointsChanging an item in a list.
The only thing I'm aware of at the moment is to .append() the list. I don't think this is what they're asking for though. How do I remove the "Treehouse" item and replace it with the first item in my name_list?
full_name = "Dan Andresen"
name_list = full_name.split()
greeting = "Hi, I'm Treehouse"
greeting_list = greeting.split()
1 Answer
Orestis Pouliasis
5,561 PointsYour code needs a little fix:
full_name = "Dan Andressen"
name_list = full_name.split()
greeting_list = "Hi, I'm Treehouse".split()
greeting_list[2] = name_list[0]
You have use split() after the string "Hi, I'm Treehouse". The last line of code is indexing and says to take index spot 2 (="Treehouse") and then it changes the index spot 2 with the name_list index spot 0(="Dan") I made you understand, couldn't explain it better.
Dan Andresen
Courses Plus Student 636 PointsDan Andresen
Courses Plus Student 636 PointsOhh I understand, guess I was over thinking it a bit. Thanks a lot.