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

Challange 3 of 3 Shopping List

Here is the question: Lastly, change the "X" in greeting_list to the first item in your name_list variable. Then join this list back into a string and store it in the variable greeting. You should end up with "Hi, I'm <your first name>".

Here is my code: full_name = "Chedva Haber" name_list = full_name.split() greeting_list = "Hi, I'm X".split() greeting_list.append(name_list) greeting = join(greeting_list)

What am I missing?

2 Answers

Samuel Webb
Samuel Webb
25,370 Points

So firstly, you're appending name_list on the back of greeting_list. What you actually want to do is replace the 'X' with the first list item in name_list which should be Chedva. Secondly, your 'join' command is incorrect. After a bit of fiddling around, I was finally able to figure out why I was also having an issue with this. The code that worked for me is as follows:

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

Hope this helps.

Hi my code below works on my shell but not in Treehouse, why?

full_name = "Evanson Brown"
name_list = list(full_name.split())
greeting_list = list("Hi, I'm {}".format(name_list[0]))
greeting = ' '.join(greeting_list)
Samuel Webb
Samuel Webb
25,370 Points

It doesn't work, because removing the 'X".split(" ")' and doing .format changes challenge 2. Although it will get you to the same result, you still have to be able to pass the first and second challenges. Which is why you have to replace the 'X' with a completely different command.

I see your point, even though the instructions says to remove (replace) the 'X'. I did keep challenge 2 intact and that did the trick.

Samuel Webb
Samuel Webb
25,370 Points

Glad I could help. Cheers mate.