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

Anthony Macias
Anthony Macias
11,220 Points

stuck on list challenge

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!

6 Answers

So.... what's your question?

name_list --> this should equal the first, middle and last name as list elements. However you shouldn't just type them in. That's so 1980's.

Check this out and see if you can apply it to your full_name variable.

<pre>

>>> word = "This is some random text"

>>> words2 = word.split(" ")

>>> words

['This', 'is', 'some', 'random', 'text']
</pre>

You can use the split() method on your full_name variable.

Tony Brackins
Tony Brackins
28,766 Points

full_name = "Full Name" name_list = full_name.split(" ")

Mark Long
Mark Long
15,763 Points

The first challenge passed with:

full_name = "Steven Mark Long" name_list = full_name.split(" ")

Then when I attempted to answer the second challenge I received a message that says "Oops! It looks like Task 1 is no longer passing."

What gives?

Daniel Chan
Daniel Chan
11,787 Points

Yes you can do it simply like this:

full_name = 'Firstname Middlename Lastname'
name_list = ' '.split(full_name)
>>>name_list
['Firstname', 'Middlename', 'Lastname']
Aman Kumaran
Aman Kumaran
2,314 Points

you have used the wrong code, that type of code is for join, not split :)

Aman Kumaran
Aman Kumaran
2,314 Points

you have used the wrong code, that type of code is for join, not split :)

Aman Kumaran
Aman Kumaran
2,314 Points

you have used the wrong code, that type of code is for join, not split :)