Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

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.

greeting_list.py
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
MOD
Chris Freeman
Treehouse Moderator 68,082 Points

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