Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

Python Python Basics (Retired) Shopping List Lists and Strings

Python

I am stuck on step three. How do I complete this step?

My code is below

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

greeting_list.py
full_name = "Koei"
name_list = full_name.split()
greeting_list = "Hi, I'm []".format(name_list[0]).split()

9 Answers

Chris Freeman
MOD
Chris Freeman
Treehouse Moderator 67,989 Points

Square brackets [] need to be curly braces {} in the formatted string. Also, it asked for a full name, not just a single name. Perhaps, change your first line to:

full_name = "Koei Superstar"

Thank you. I figured out that one as soon as I posted it. But now I am stuck on number 4. It gives me a error that said "Your name_list's last item shouldn't be in your greeting variable!"

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

Chris Freeman
Chris Freeman
Treehouse Moderator 67,989 Points

I've also retried the challenge and I'm getting an unexplained error message that I believe is incorrect. I've posted my issue here and tagged Kenneth Love to see what the issue is.

Here is the answer for part 4/4:

full_name = "Koei Superstar"
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 I wrote "Koei Superstar" then it splits it into "Koei" and "Superstar"

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="koei")

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

Kenneth Love
STAFF
Kenneth Love
Treehouse Guest Teacher

The challenge is expecting a name with at least two parts (so name_list will have at least two parts). Also, greeting_list needs to be, as named, a list.

Jamison, I understood what you did. A list starts at the zeroth element and that is why you replaced Treehouse with the zeroth element of the full_name. I still do not understand how to only print out the zeroth element of full_name when I have already embedded that into greeting_list.

Right now, I have this:

full_name = "Koei Superstar" name_list = full_name.split()

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

greeting = " ".join(greeting_list)

This prints out, "Hi, I'm Koei Superstar." When Im supposed to get "Hi, I'm Koei."

Jamison, I understood what you did. A list starts at the zeroth element and that is why you replaced Treehouse with the zeroth element of the full_name. I still do not understand how to only print out the zeroth element of full_name when I have already embedded that into greeting_list.

Right now, I have this:

full_name = "Koei Superstar" name_list = full_name.split()

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

greeting = " ".join(greeting_list)

This prints out, "Hi, I'm Koei Superstar." When Im supposed to get "Hi, I'm Koei."

Chris Freeman
Chris Freeman
Treehouse Moderator 67,989 Points

In line 2, you are re-splitting full_name and adding it to greeting_list. Try using name_list[0] in the format():

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

Oh. They wanted me to rewrite the code on line 2. I thought they wanted us to use the existing code. Ill try that.

Chris Freeman
Chris Freeman
Treehouse Moderator 67,989 Points

It's not that they specifically want you to rewrite the code for Step 2. It's that some code that passes Step 2 won't work in Step 3. When you get you solution for Step 3, try it in Step 2 as an alternate approach. In trying various examples for this challenge, I also found code that passed Step 2 and fails in Step 3. Good Luck!

Thank you I got it!

Thank you I got it!