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 trialRyan Hemrick
12,759 PointsStuck on Challenge Task 3 of Shopping List
This is what I have. What is wrong?
`full_name = "Ryan Hemrick"
name_list = full_name.split(' ')
greeting_list = "Hi, I'm name_list[0]".split(' ')
greeting = greeting_list`
3 Answers
nvcxnvkldsjaklfds
Courses Plus Student 5,041 PointsThe problem is in line 3.
greeting_list = "Hi, I'm name_list[0]".split(' ')
What you are trying to do is split "Hi, I am name_list[0]" by whitespace. So after executing line 3 the value of greeting_list will be ['Hi', 'I'm', 'name_list[0]']
Python can't recognize name_list[0] as a value or variable index because it is inside double quote.
Anything inside double quotes are treated as a string by Python.
I hope i answer your question.
nvcxnvkldsjaklfds
Courses Plus Student 5,041 PointsThis is code
full_name = "Karthikeyan Palaniswamy"
name_list = full_name.split()
greeting_list = "Hi, I'm X".split()
greeting_list[2] = name_list[0]
greeting = ' '.join(greeting_list)
nvcxnvkldsjaklfds
Courses Plus Student 5,041 PointsYou can include any code using following guidelines
Code Wrap your code with 3 backticks (```) on the line before and after. If you specify the language after the first set of backticks, that'll help us with syntax highlighting.
```html
<p>This is code!</p>
```
I hope i answer your answer.
Ryan Hemrick
12,759 PointsRyan Hemrick
12,759 PointsThank you! And how do I copy my code from the code challenge directly into my post? Such as you have in your post?