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

Martel Gaines
Martel Gaines
1,957 Points

My full name entered as a list variable

I'm having an issue with inputting my full name as a list function for name_list variable. I'm currently performing the following action: name_list = list("Martel," "Gaines") or using the existing variable of full_name = "Martel Gaines as name_list = list(full_name)

I'm being returned an error that my name does not match my full name. Has anyone been stuck on this challenge?

full_name = "Martel Gaines"
name_list = list("Martel Gaines")

1 Answer

William Li
William Li
Courses Plus Student 26,865 Points

In your code, the value of name_list would becomes

# => ['M', 'a', 'r', 't', 'e', 'l', ' ', 'G', 'a', 'i', 'n', 'e', 's']

What the challenge is expecting the name_list to be is ["Martel", "Gaines"]

Hint: Use the .split() method on the string.

Martel Gaines
Martel Gaines
1,957 Points

Thanks Will, much appreciated! The .split() method resolved it all along.