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

Python Python Basics (Retired) Shopping List Lists and Strings

David Fry
David Fry
13,267 Points

How come this does not pass the test on part 4

I am having problems with part 4 on this code challenge.

full_name = "David Fry"
name_list = full_name.split()
greeting_list = "Hi, I'm".split() + name_list
greeting = " ".join(greeting_list)

2 Answers

You created a list called name_list that looks like ['David', 'Fry']. The challenge is expecting "Hi, I'm David". To accomplish this, access the first item in name_list via an index. In this case, 'David' is the first item in name_list, so you would access it via name_list[0].

greeting_list = "Hi, I'm".split() + name_list[0]
Chris Freeman
Chris Freeman
Treehouse Moderator 68,423 Points

You are adding your entire name_list to greeting_list. So your first and last name is present.