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

Create a variable named greeting_list that's the string "Hi, I'm Treehouse" split on the spaces.

Create a variable named greeting_list that's the string "Hi, I'm Treehouse" split on the spaces.

greeting_list.py
full_name="nyasha chawanda"
name_list=full_name.split()
greeting_list="Hi,i'm Treehouse".split()

4 Answers

Manuel Tarazona
Manuel Tarazona
5,282 Points

Your code isn't working because you are calling split without specifying where it should be split. The split method should always be called on the string you want to split with where you want the the string to be split in between the brackets in string form. In this case, your code should be:

full_name="nyasha chawanda"
name_list=full_name.split(" ")
greeting_list="Hi,i'm Treehouse".split(" ")

It was missing the " " between the brackets in the split method.

Kenneth Love
Kenneth Love
Treehouse Guest Teacher

"Hello there".split() and "Hello there".split(" ") will produce exactly the same output. .split(), with no arguments, splits on whitespace (spaces, tabs, new lines).

Kenneth Love
STAFF
Kenneth Love
Treehouse Guest Teacher

Spacing and capitalization is important. Your greeting_list string should be "Hi, I'm Treehouse" with capital letters on each word and a space after the comma. Yes, it's picky. So is programming :)

Christian Linnerud
Christian Linnerud
7,312 Points

Like this:

greeting_list="Hi, I'm Treehouse".split()

greeting_list = "Hi, I'm Treehouse".split()