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

Patrick Wheat
Patrick Wheat
2,641 Points

Not sure what I should be using to get my name_list to print just the space between my first and last name.

Right now it is putting spaces between all of my letters instead of just in between my first and last name, should I be using the str.join in this question

greeting_list.py
full_name = ('Patrick Wheat')
name_list = list(full_name)

1 Answer

Hi Patrick,

Calling list() passing in a string will create a list where each element is a single character. Instead, we want to use the split() method.

Make another variable named name_list that holds your full name as a list, split on the spaces.

It can help to experiment with a Python REPL.

python

Hope this helps,

Cheers

Patrick Wheat
Patrick Wheat
2,641 Points

Robert, Thanks for the clarification and the code in an example. I get it better than I did from the class now that I see it formatted that way! Great answer, appreciate the help.