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

Gokul Ravichandran
Gokul Ravichandran
209 Points

name_list query

name_list query

greeting_list.py
full_name="gokul pradeep"
name_list=list(full_name).split()

Do you have a question tied to this?

2 Answers

I'm assuming you are on Task 1 for the challenge. The issue here is that you don't need to declare full name as a list, as the .split() function will return the words as a list.

full_name="gokul pradeep"
name_list=full_name.split()
Chris Freeman
MOD
Chris Freeman
Treehouse Moderator 68,441 Points

The issue in your current code is a list object does not have a method .split(). Strings have the method split() which returns a list of the split items. The default split is on whitespace.

Removing the list() wrapper from around full_name will fix this:

full_name = "gokul pradeep"
name_list = full_name.split()

In terms of style, in an assignment statement it is customary to add a space on both sides of an equals (=) sign