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 trial
Lisa Sparks
3,187 Pointshaving problems with changing "Treehouse" in greeting_list to the first item in your name_list variable.
change "Treehouse" in greeting_list to the first item in your name_list variable.
7 Answers
Benjamin Balzer
937 PointsI believe that what you're looking for, essentially, is this? Do you see how that works? Let me know. :)
full_name = ("Lisa Sparks")
name_list = full_name.split()
greeting_list = "Hi, I'm Lisa".split()
greeting_list[len(greeting_list) - 1] = name_list[0]
greeting = " ".join(greeting_list)
print (greeting)
Brian Finkelstein
1,767 PointsHi Lisa, I don't recall the exact problem but hopefully this helps. If the name_list looks like this: name_list = ['John','Jacob','Jingleheimerschmidt']
To set the variable named Treehouse to the value of the first item you must use a notation that references the index (or position). This notation for indexes of lists starts at 0 so your syntax would be something like:
Treehouse = name_list[0]
The Treehouse variable in my example would now have the value 'John'. Hope this helps!
Lisa Sparks
3,187 PointsHello, Brian I tried your example, but It didn't work.
Lisa Sparks
3,187 Pointsyes it worked thanks
Benjamin Balzer
937 PointsGimme a thumbs-up on the right, there? Thanks, and I'm glad I could help! :)
Mike Anthony
3,815 PointsI got this error: Your name_list's first item doesn't seem to be in your greeting_list!
when trying to change the value of the word Treehouse in the greeting list to the value of the first item in the name list as so:
greeting_list[3] = name_list[0]
Any ideas why this throws that error? I thought I was on the right track here. Thanks for any help!
Dennis Mayo
13,508 PointsMike, I did not think of approaching the problem this way. It works and is very simple. The only problem with your code is that the "Treehouse" item is in location [2] and not [3]. If you change that your answer will work.
Lisa Sparks
3,187 PointsThanks