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

Martel Gaines
Martel Gaines
1,957 Points

Challenge Task 4 of 4: Greeting variable joining my greeting list back into a string.

Hi Team Python,

I'm stuck on this last line for my final task of the challenge where I need to take the greeting variable and join the greeting_list back into a string, where it would read out "Hi, I'm Martel" Can someone provide help on the join argument please?

greeting_list.py
full_name = "Martel Gaines"
name_list = "Martel Gaines".split()
greeting_list = "Hi, I'm Treehouse".split()
greeting_list [2] = name_list [0]
greeting = "Hi, I'm Martel".join(
#check documentation for the join method it should be like as follows
greeting = " ".join(greeting_list)

1 Answer

Chris Freeman
MOD
Chris Freeman
Treehouse Moderator 68,441 Points

The join() is a string method that uses a string as the "glue" between items in a list. To join a list with a space separator use:

greeting = " ".join(greeting_list)

This is one of the unusual aspects of python. In that you would think there would be a list method that joined its items give a string. Though it doesn't look like it, this is FAST and it is preferred over using a series of ``string =+ " additional text"

Martel Gaines
Martel Gaines
1,957 Points

Thx Chris, very helpful!