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

joining strings

Great! Finally, make a variable named greeting where you join greeting_list back into a string, separated by spaces. You should end up with "Hi, I'm <your first name>" as the value of greeting. cant seem to get it

greeting_list.py
full_name = "chey pettitt"
name_list = full_name.split(" ")
greeting_list = "Hi, I'm chey".split(" ")
greeting = .join("greeting_list")

5 Answers

What variables are you starting with? Do you mean like this:

In [1]: greeting_list = "Hi, I'm chey".split(" ")

In [2]: greeting_list Out[2]: ['Hi,', "I'm", 'chey']

In [3]: space = " "

In [4]: greeting = space.join(greeting_list)

In [5]: greeting Out[5]: "Hi, I'm chey"

Hi Chey,

Do you mean like this:

In [9]: greeting = "Hi, I'm " + full_name

In [10]: greeting Out[10]: "Hi, I'm chey pettitt"

Or do you need to take a list of strings and construct the sentence?

should end up with greeting = hi im chey so do i write like greeting = greeting list somehow

got it!! must be getting confused to set the same values i just added same string so;

greeting = "Hi, I'm chey"

thats a better sum of events i could do it that way thanks ryan

Glad I could help