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

Chris Freeman
MOD
Chris Freeman
Treehouse Moderator 68,423 Points

Challenge question error message seems wrong

In Shopping List Stage 4, Challenge Step 3 of 4: Almost done! Now, change "Treehouse" in greeting_list to the first item in your name_list variable.

I believe my code is correct, but still getting error message. Using Preview to check the output.html it seems the error message is incorrect.

EDIT: I see that greeting_list with the extra 'from' is not exactly as stated in Step 2. However, when including the extra word, the code passes Step 2, perhaps due to relaxed validation. Given passing code in Step 2, the error seems misplaced since the instructions for Step 3, only say to change a greeting_list list item not regarding the specific position of "Treehouse".

Suggestion to Treehouse Developers: Change Step 2 to verify greeting_list[2] = "Treehouse" or in Step 3 allow for greeting_name[-1] == name_list[0]

Code:

full_name = "Chris Freeman"
name_list = full_name.split()
greeting_list = "Hi, I'm from Treehouse".split()
greeting_list[3] = name_list[0]

Result output.html:

Variable        Value
greeting_list   ['Hi,', "I'm", 'from', 'Chris']
input       
__name__    __main__
full_name   Chris Freeman
name_list       ['Chris', 'Freeman']

But I get the error when checking work:

Bummer! Your name_list's first item doesn't seem to be in your greeting_list!

Looking at the output.html, the first item from name_list ('Chris') is clearly in my greeting_list in the place of the original 'Treehouse'.

Looking to Kenneth Love for feedback! (See EDITs above)

3 Answers

Here is the answer for part 4/4:

full_name = "Chris Freeman"
name_list = full_name.split()

greeting_list = "Hi, I'm Treehouse".split()

greeting_list[2] = name_list[0]

what this is doing is taking your full name then it splits it into "Chris" and "Freeman"

greeting_list is split into "Hi" "I'm" "Treehouse"

take index spot 2 (which is "Treehouse" start counting at 0. 0 = Hi, 1 = I'm, 2= Treehouse) and change index spot 2 to name_list index spot 0 (0="Chris")

Hope this helps! please mark for best answer if it helped!!

you just miscounted the index location because you added the word "from", otherwise you would be correct!

Chris Freeman
Chris Freeman
Treehouse Moderator 68,423 Points

Thanks Jamison. I still have issue with the erroneously stated message that claims first_name is "not part of the greeting_list". It should state instead that item is not in expected position",

I submitted it exactly how I presented it here and it have back 0 errors. It completed the challenge so I guess I'm not sure what's going on.

Chris Freeman
Chris Freeman
Treehouse Moderator 68,423 Points

Thanks. I see the errors and I've edited the original question. At this point its more about validation in Step 2 and misleading error messages in Step 3. Specifically, I feel code passing earlier stages shouldn't be subsequently rejected for non-obvious reason. The real error was "The code from Step 2, wasn't actually correct".

Xiaoqian Zhou
Xiaoqian Zhou
6,506 Points

I think this question is asking for a for loop that checks each list item and if it's "Treehouse" then change it to name_list[0]...

Thomas Kirk
Thomas Kirk
5,246 Points

The task asks for "Hi, I'm Treehouse", not "Hi, I'm from Treehouse"

As such, there is no greeting_list [3]

Chris Freeman
Chris Freeman
Treehouse Moderator 68,423 Points

Thanks. It seems that the challenge migrated from "Hi, I'm from X" to "Hi, I'm Treehouse" at some point. I still have issue with the erroneously stated message that claims first_name is "not part of the greeting_list". It should state instead that item is not in expected position",