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 trialbilladama
Python Web Development Techdegree Student 5,251 PointsOn task 3/3 I keep getting the message that task one is no longer passing although I've done nothing to change it
Can you clear this up?
full_name = 'Daniel Strong'
name_list = full_name.split()
#greet = "Hi, I'm" + full_name[0]
greeting_list = "Hi, I'm" + name_list[0].split() #+ name_list[0].split() #+ full_name[0].split()
greeting = ''.join(greeting_list)
2 Answers
Mikael Enarsson
7,056 PointsYou are going about this in the wrong way. Outlining the tasks in the challenge:
Create a string with your name and split it into a list. This one is fine.
Split the string "Hello, I'm X" on the spaces. You aren't doing this in your code.
Insert your name in the position that X has in greeting_list and join it into a string, This is where you went wrong, I think you went back and replaced the code from task two with
greeting_list = "Hi, I'm" + name_list[0].split()
trying to concatenate a string with a list item (which is apparently not allowed, and thus a syntax error, which is why you got "Task 1 no longer passing").
What they want you to do is take the greeting list you created earlier, and replace 'X' with the first item in name_list (by assigning the value at the first position in name_list to the list position in greeting_list that holds 'X'). You're almost there, by the looks of it.
The rest is fine, mostly.
Oh, and sorry if I sound a bit gruff, but it's late-ish over here. I hope you can forgive me ^^
billadama
Python Web Development Techdegree Student 5,251 PointsThank you so much, Mikael and Kenneth! That worked great and was surprisingly easy.
Mikael Enarsson
7,056 PointsNo worries ^^
Kenneth Love
Treehouse Guest TeacherKenneth Love
Treehouse Guest TeacherAdding a list item to a string, assuming the item is a string itself, is fine. The problem is the order these actions are done in.
Here's how Python sees it.
Now doing it with an explicit order-of-operations would make it work.
greeting_list = ("Hi, I'm " + name_list[0]).split()
Also, you want a space before the string ends, so I've added that in.
Mikael Enarsson
7,056 PointsMikael Enarsson
7,056 PointsAah, of course, I should have seen that! I still have some way to go, it seems.