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 Python Basics (Retired) Shopping List Lists and Strings

Changing one variable. change "Treehouse" in greeting_list to the first item in your name_list variable.

Have I used up all my questions? I no longer get any help. My question is, How do I change "Treehouse" in my greeting_list to the first item in your name_list variable? Please assist me in solving this because I'm stuck. Thanks very much.

greeting_list.py
full_name = "terence kelley"
name_list = "terence kelley"
name_list = full_name.split()
greeting_list = "Hi, I'm Treehouse".split()
greeting_list = "Terence"

2 Answers

Gunhoo Yoon
Gunhoo Yoon
5,027 Points

Everything looks good except for 2 lines.

name_list = "terence kelley" # not needed

You can simply remove above line.

greeting_list = "Terence" # doesn't do what question asks for

Given task is to change last element of greeting_list to first element of name_list.

The index of last item in the list can always be referred as -1

The index of first item in the list can always be referred as 0

greeting_list[-1] = name_list[0]

Last step is joining greeting_list in greeting variable.

Join() works as follow separator.join(list)

greeting = ' '.join(greeting_list) # Space character is used.

Given task is to change last element of greeting_list to first element of name_list.

The index of last item in the list can always be referred as -1 (I still don't understand this)

The index of first item in the list can always be referred as 0(I still do not understand this) please explain. greeting = ' '.join(greeting_list) # Space character is used. (This is unclear and not explained. I still do not understand this) please explain.