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

Python Help

My code is

full_name = "Jake Zeal"
name_list = full_name.split()
greeting_list = "Hi, I'm {}".format(name_list[0]).split()
greeting = "{}".format(greeting_list).join()

But it does not pass.


Or step 3 would be something like:

full_name = "Jake Zeal"
name_list = full_name.split()
greeting_list = "Hi, I'm Treehouse".format(greeting_list[3])(name_list[0]).split()

However greeting_list is not yet defined. Hmmm

1 Answer

Seth Kroger
Seth Kroger
56,413 Points

Keep task 2 and 3 on separate lines. You also shouldn't need format() because the string for join() in step 4 should only be what goes between list items. join() will do the rest.

# task 1
full_name = "Seth Kroger"
name_list = full_name.split()

# task 2
greeting_list = "Hi, I'm Treehouse".split()

# task 3
greeting_list[-1] = name_list[0]  # or greeting_list[2] but I like the last item syntax better.

# task 4
greeting = " ".join(greeting_list)

Awesome thanks ! I will try it out now