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

Task 3 f 3

I've been stuck on it for the longest time What do I use to put the first item of name_list into "Hi, I'm X"?

1 Answer

Hey Brandon!

The code should be as follows:

full_name = "Your name"
name_list = full_name.split()
greeting_list = "Hi, I'm X".split()
greeting_list[2] = name_list[0]
greeting = " ".join(greeting_list)

If you don't understand any of the code feel free to reply and I will walk through it with you!

Have a great day!

-Luke

Khaleel Hamid
Khaleel Hamid
5,258 Points

I understand the first 3, but could you elaborate on the last two lines of codes

greeting_list[2] = name_list[0] greeting = " ".join(greeting_list)

Hi Khaleel!

The first line you mentioned sets the "X" in greeting_list equal to the first section of name list.

The second line is used to convert the list into a string by "joining" each of the list items with a space.

If you are still having problems understanding the code feel free to ask more questions!

-Luke

Khaleel Hamid
Khaleel Hamid
5,258 Points

Thanks Luke that makes sense now.