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

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 =)