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

Logesh Jayaraman
Logesh Jayaraman
445 Points

Error on Task

Your greeting doesn't seem to be the right string! Got 'Hi, I'm Logesh Jayaraman', expected 'Hi, I'm Logesh Jayaraman'. what did i miss?

greeting_list.py
full_name = "Logesh Jayaraman"
name_list = full_name.split()
greeting_list = "Hi, I'm {}".format(full_name).split()
greeting = '  '.join(greeting_list)

2 Answers

Michael Rawlinson
Michael Rawlinson
1,507 Points

Okay there are two things which need changing. The first is that it says it only wants your first name not your full name which you have stored in full_name. The second is that you need one space between the ' ' not two spaces. The code I used which passed is this:

full_name = "Michael Rawlinson";
name_list = full_name.split();
greeting_list = "Hi, I'm Treehouse".split();
greeting_list[2] = name_list[0];
greeting = " ".join(greeting_list)
Jason Anders
Jason Anders
Treehouse Moderator 145,860 Points

Hey Michael,

Good catch on the extra space. I missed that.

I also edited you answer to markdown the code so it's more readable. You do this with 3 back-ticks. If you go in to 'edit' your answer, you will see how I did it.

This Previous Treehouse Post is very helpful with posting code to the forum.

Keep Coding! :)

Michael Rawlinson
Michael Rawlinson
1,507 Points

Thank you! I have been trying to find out how to do that for awhile.

Jason Anders
MOD
Jason Anders
Treehouse Moderator 145,860 Points

Hi Logesh,

I'm not really sure why your code passed the 3rd part of the challenge, but that's what's tripping you up in the 4th task.

The 3rd part says to "change "Treehouse" in greeting_list to the first item in your name_list variable." To do this you need to change the full_name that you passed in to name_list[0] to grab the first item.

In the final task, once that change is made, your code is correct!

So, just change

greeting_list = "Hi, I'm {}".format(full_name).split()

to

greeting_list = "Hi, I'm {}".format(name_list[0]).split()

Keep Coding! :)