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

James Male
James Male
6,619 Points

Python Code Challenge

I am unble to pass task 2 of the code challenge and cannot understand why.

My code:

full_name = "James"
name_list = full_name.split()
greeting_list = "Hi, I'm {}".format(full_name)

2 Answers

Misha Shaposhnikov
Misha Shaposhnikov
8,718 Points

The program expects for your full name to be comprised of several words, separated by spaces. Then, when you call full_name.split(), you have to pass it a string that tells the method what character you want to use as the separator. Otherwise, .split() doesn't know how to change the string into a list of smaller strings. And for Task 2, you have to just split the literal string "Hi, I'm X". You will change 'X' to your name in Task 3. Here is my example:

full_name = "Misha Pavlovich Shaposhnikov";
name_list = full_name.split(" ");
// Now name_list is ["Misha" , "Pavlovich" , "Shaposhnikov"]
greeting_list = "Hi, I'm X".split(" ");
// Now greeting_list is ["Hi," , "I'm" , "X"]

Happy Coding! =)

James Male
James Male
6,619 Points

Thank you Misha =)