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
Diego Murray
2,515 PointsPython Basics - HELP
QUESTION Great! Finally, make a variable named greeting where you join greeting_list back into a string, separated by spaces. You should end up with "Hi, I'm <your first name>" as the value of greeting.
MY CODE
full_name = "Diego Murray"
name_list = (full_name).split(" ")
greeting_list = "Hi, I'm {}".format(full_name).split()
greeting_list[2] = name_list[0]
greeting = " ".join(greeting_list)
CODE CHALLENGE RESPONSE
Bummer! Your name_list's last item shouldn't be in your greeting variable!
I put this code in the SHELL and it seemed to work fine.
3 Answers
rydavim
18,814 PointsI think your greeting_string may not be what the challenge is requesting. The code for that specific step looks good.
full_name = "Diego Murray"
name_list = (full_name).split(" ")
# This is equal to ["Hi," "I'm", "Diego", "Murray"]
# greeting_list = "Hi, I'm {}".format(full_name).split()
greeting_list = "Hi, I'm Treehouse.".split() # I added this line to test your step code below.
greeting_list[2] = name_list[0]
greeting = " ".join(greeting_list)
Gunhoo Yoon
5,027 PointsThe correct answer that makes grader happy is this version.
full_name = "Diego Murray"
name_list = full_name.split(" ")
greeting_list = "Hi, I'm Treehouse".split(" ")
greeting_list[2] = name_list[0]
greeting = " ".join(greeting_list)
The grader expects your greeting_list to use split method.
Alternatively you can do this as well.
full_name = "Diego Murray"
#name_list = (full_name).split(" ")
#greeting_list = "Hi, I'm {}".format(full_name).split()
#This is probably what you thought at the beginning.
#If you do this you don't need further code. Maybe that's why grader didn't accept yours.
greeting_list = "Hi, I'm {}".format(full_name.split(" ")[0])
#Not required.
#greeting_list[2] = name_list[0]
#greeting = " ".join(greeting_list)
I also want to add what your mistake will actually result into
#assume previous code has been written
greeting_list = "Hi, I'm {}".format(full_name).split()
Here's step by step what your line will do.
"Hi, I'm Diego Murray".split()
["Hi,", "I'm", "Diego", "Murray"]
Diego Murray
2,515 PointsGunhoo Yoon
5,027 PointsThanks give me a minute
Gunhoo Yoon
5,027 PointsGunhoo Yoon
5,027 PointsDo you mind linking me to the question?