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

Python

having 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

I 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)

Hi 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!

Hello, Brian I tried your example, but It didn't work.

yes it worked thanks

Gimme a thumbs-up on the right, there? Thanks, and I'm glad I could help! :)

I 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!

Mike, 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.

Thanks