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

thanh trung
thanh trung
4,246 Points

shopping list

i dont understand code challenge task 3 of 3. i dont understand what they want. can somebody explain please?

3 Answers

Hey Thanh!

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

First you are asked to set the "X" in greeting list equal to your first name that is stored in the name_list variable. This is done using the line below:

greeting_list[2] = name_list[0]

Then you are asked to join the greeting_list together into a variable called greeting. That is done using the code below:

greeting = " ".join(greeting_list)

If you do not understand the solution or how it works then please feel free to ask!

-Luke

thanh trung
thanh trung
4,246 Points

what does greeting_lsit[2] = name_list[0] mean. "X" isnt at index 2 now, is it?

greeting_list[2] contains 'X' and then we are setting that equal to what is at index 0 in name_list, which in this case is 'Full'.

No problem, good luck with the rest of the course!

Also, Thanh! Remember to mark a best answer so other Treehouse members know that your problem has been solved!

Thanks!

-Luke