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 trialw h
1,723 PointsPython
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()
full_name = "Koei"
name_list = full_name.split()
greeting_list = "Hi, I'm []".format(name_list[0]).split()
9 Answers
Chris Freeman
Treehouse Moderator 68,428 PointsSquare 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"
w h
1,723 PointsThank 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
Treehouse Moderator 68,428 PointsI'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.
Jamison Imhoff
12,460 PointsHere 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
Treehouse Guest TeacherThe 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.
w h
1,723 PointsJamison, 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."
w h
1,723 PointsJamison, 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
Treehouse Moderator 68,428 PointsIn 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()
w h
1,723 PointsOh. 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
Treehouse Moderator 68,428 PointsIt'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!
w h
1,723 PointsThank you I got it!
w h
1,723 PointsThank you I got it!