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

Ryan Dodds
Ryan Dodds
4,418 Points

How do I structure the "Hi, I'm ... string so that it includes the first item in my "full_name" list?

I'm stuck on replacing "Treehouse" with my First Name. Any hints?

greeting_list.py
full_name = 'Ryan Dodds'

name_list = full_name.split()

greeting_list = "Hi, I'm {}".format(full_name[0])

3 Answers

full_name = [Ryan Dodds]

does this work? =D

Sean T. Unwin
Sean T. Unwin
28,690 Points

I think you accidently referenced full_name when you meant to reference name_list.

greeting_list = "Hi, I'm {}".format(full_name[0])

# should be 

greeting_list = "Hi, I'm {}".format(name_list[0])

If you're looking to output, "Hi, I'm Ryan", you could use this:

greeting_list = "Hi, I'm {}".format(full_name[:full_name.find(' ')])

This will output the text which comes before the first space found in the string and save you creating a variable.

Ryan Dodds
Ryan Dodds
4,418 Points

Thanks, Sean! I'll give this a go.

Ryan Dodds
Ryan Dodds
4,418 Points

Hmmm...Sean, that doesnt seem to be working. Any other ideas?

Sean T. Unwin
Sean T. Unwin
28,690 Points

Hi there Ryan,

We need to replace the 3rd item in greeting_list with the first item in name_list.

full_name = 'Ryan Dodds'
name_list = full_name.split()

greeting_list = ["Hi,", "I'm", "Treehouse"]
greeting_list[2] = name_list[0]

I didn't realize this was for a challenge with my other answer.