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

What am I doing wrong?

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

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
William Li
Courses Plus Student 26,868 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.