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

What am I doing wrong?

Can anybody tell me what's wrong with this code?

greeting_list.py
full_name = "Ira Salem"
name_list = list(full_name)

Create a variable named full_name that holds your full name. Make another variable named name_list that holds your full name as a list, split on the spaces. Don't create name_list manually!

2 Answers

William Li
PLUS
William Li
Courses Plus Student 26,867 Points

Hi, Ira, you need to use the split method to solve this problem

name_list = full_name.split(" ")

The when you call the list on a string, in your case, list(full_name), it'll return a list by split the string character by character ['I', 'r', 'a', ' ', 'S', 'a', 'l', 'e', 'm']. That's not quite what the question is asking for.

It's crazy but I don't recall him ever showing that we could even use the .split method that way. Either that or I'm not taking very good notes. Thanks anyway. I'll give it a try soon as I get home.

Kenneth Love
Kenneth Love
Treehouse Guest Teacher

Hey Ira Salem. It's a couple of videos back but we definitely used .split() on a string.

Perhaps I should utilize the transcript portion more. I'll definitely go back and look.