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

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